Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-04-19 07:25:49
Exec Total Coverage
Lines: 8588 12199 70.4%
Functions: 77 106 72.6%
Branches: 5385 9965 54.0%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #ifndef __GTHREAD_HIDE_WIN32API
12 #define __GTHREAD_HIDE_WIN32API 1
13 #endif //prevent indirectly including windows.h
14
15 #include "precompiled.h" //always first
16
17
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 #include <stdio.h>
18 #include <string.h>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23 #include <fmt/format.h>
24
25
26 #include "metadata/sigs/devsig.h.sig"
27 #include "metadata/sigs/compilersig.h.sig"
28 #include "metadata/versionsig.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "qst.h"
35 //#include "zquest.h"
36 #include "defdata.h"
37 #include "subscr.h"
38 #include "font.h"
39 #include "zc_custom.h"
40 #include "sfx.h"
41 #include "md5.h"
42 #include "ffscript.h"
43 #include "particles.h"
44 #include "dialog/alert.h"
45 //FFScript FFCore;
46 extern FFScript FFCore;
47 extern ZModule zcm;
48 extern zcmodule moduledata;
49 extern uint8_t __isZQuest;
50 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
51 extern particle_list particles;
52 extern void setZScriptVersion(int32_t s_version);
53 //FFSCript FFEngine;
54
55 int32_t temp_ffscript_version = 0;
56 static bool read_ext_zinfo = false, read_zinfo = false;
57 static bool loadquest_report = false;
58 static char const* loading_qst_name = NULL;
59 static byte loading_qst_num = 0;
60
61 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
62 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
63
64 #ifdef _MSC_VER
65 #define strncasecmp _strnicmp
66 #endif
67
68 #ifndef _AL_MALLOC
69 #define _AL_MALLOC(a) _al_malloc(a)
70 #define _AL_FREE(a) _al_free(a)
71 #endif
72
73 using std::string;
74 using std::pair;
75
76 // extern bool debug;
77 extern int32_t hero_animation_speed; //lower is faster animation
78 extern std::vector<mapscr> TheMaps;
79 extern zcmap *ZCMaps;
80 extern MsgStr *MsgStrings;
81 extern DoorComboSet *DoorComboSets;
82 extern dmap *DMaps;
83 extern newcombo *combobuf;
84 extern byte *colordata;
85 //extern byte *tilebuf;
86 extern tiledata *newtilebuf;
87 extern byte *trashbuf;
88 extern itemdata *itemsbuf;
89 extern wpndata *wpnsbuf;
90 extern comboclass *combo_class_buf;
91 extern guydata *guysbuf;
92 extern ZCHEATS zcheats;
93 extern zinitdata zinit;
94 extern char palnames[MAXLEVELS][17];
95 extern int32_t memrequested;
96 extern char *byte_conversion(int32_t number, int32_t format);
97 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
98 31 string zScript;
99 31 std::map<int32_t, script_slot_data > ffcmap;
100 31 std::map<int32_t, script_slot_data > globalmap;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
31 std::map<int32_t, script_slot_data > genericmap;
102 31 std::map<int32_t, script_slot_data > itemmap;
103 31 std::map<int32_t, script_slot_data > npcmap;
104 31 std::map<int32_t, script_slot_data > ewpnmap;
105 31 std::map<int32_t, script_slot_data > lwpnmap;
106 31 std::map<int32_t, script_slot_data > playermap;
107 31 std::map<int32_t, script_slot_data > dmapmap;
108 31 std::map<int32_t, script_slot_data > screenmap;
109 31 std::map<int32_t, script_slot_data > itemspritemap;
110 31 std::map<int32_t, script_slot_data > comboscriptmap;
111 void free_newtilebuf();
112 bool combosread=false;
113 bool mapsread=false;
114 bool fixffcs=false;
115 bool fixpolsvoice=false;
116
117
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
118
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
119
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
120
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
121
122 char qstdat_string[2048] = { 0 };
123
124 static zinfo* load_tmp_zi = NULL;
125
126 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
127 const byte clavio[9]={97,109,111,110,103,117,115,0};
128
129 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
130 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
131
132 extern combo_alias combo_aliases[MAXCOMBOALIASES];
133 extern combo_pool combo_pools[MAXCOMBOPOOLS];
134 const char *qst_error[] =
135 {
136 "OK","File not found","Invalid quest file",
137 "Version not supported","Obsolete version",
138 "Missing new data" , /* but let it pass in ZQuest */
139 "Internal error occurred", "Invalid password",
140 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
141 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
142 };
143
144 //for legacy quests -DD
145 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
146 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
147 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
148 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
149 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
150 };
151
152 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
153
154
155 void delete_combo_aliases()
156 {
157 for(int32_t j(0); j<256; j++)
158 {
159 if(combo_aliases[j].combos != NULL)
160 {
161 delete[] combo_aliases[j].combos;
162 combo_aliases[j].combos=NULL;
163 }
164
165 if(combo_aliases[j].csets != NULL)
166 {
167 delete[] combo_aliases[j].csets;
168 combo_aliases[j].csets=NULL;
169 }
170 }
171
172 }
173
174 char *byte_conversion(int32_t number, int32_t format)
175 {
176 static char num_str[40];
177
178 if(format==-1) //auto
179 {
180 format=1; //bytes
181
182 if(number>1024)
183 {
184 format=2; //kilobytes
185 }
186
187 if(number>1024*1024)
188 {
189 format=3; //megabytes
190 }
191
192 if(number>1024*1024*1024)
193 {
194 format=4; //gigabytes (dude, what are you doing?)
195 }
196 }
197
198 switch(format)
199 {
200 case 1: //bytes
201 sprintf(num_str,"%db",number);
202 break;
203
204 case 2: //kilobytes
205 sprintf(num_str,"%.2fk",float(number)/1024);
206 break;
207
208 case 3: //megabytes
209 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
210 break;
211
212 case 4: //gigabytes
213 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
214 break;
215
216 default:
217 exit(1);
218 break;
219 }
220
221 return num_str;
222 }
223
224 434 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
225 {
226 static char num_str1[40];
227 static char num_str2[40];
228 static char num_str[80];
229
230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if(format1==-1) //auto
231 {
232 434 format1=1; //bytes
233
234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if(number1>1024)
235 {
236 434 format1=2; //kilobytes
237 434 }
238
239
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 124 times.
434 if(number1>1024*1024)
240 {
241 124 format1=3; //megabytes
242 124 }
243
244
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(number1>1024*1024*1024)
245 {
246 format1=4; //gigabytes (dude, what are you doing?)
247 }
248 434 }
249
250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if(format2==-1) //auto
251 {
252 434 format2=1; //bytes
253
254
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 434 times.
434 if(number2>1024)
255 {
256 434 format2=2; //kilobytes
257 434 }
258
259
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 403 times.
434 if(number2>1024*1024)
260 {
261 403 format2=3; //megabytes
262 403 }
263
264
1/2
✓ Branch 0 taken 434 times.
✗ Branch 1 not taken.
434 if(number2>1024*1024*1024)
265 {
266 format2=4; //gigabytes (dude, what are you doing?)
267 }
268 434 }
269
270
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✓ Branch 3 taken 124 times.
✗ Branch 4 not taken.
434 switch(format1)
271 {
272 case 1: //bytes
273 sprintf(num_str1,"%db",number1);
274 break;
275
276 case 2: //kilobytes
277 310 sprintf(num_str1,"%.2fk",float(number1)/1024);
278 310 break;
279
280 case 3: //megabytes
281 124 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
282 124 break;
283
284 case 4: //gigabytes
285 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
286 break;
287
288 default:
289 exit(1);
290 break;
291 }
292
293
2/5
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 403 times.
✗ Branch 4 not taken.
434 switch(format2)
294 {
295 case 1: //bytes
296 sprintf(num_str2,"%db",number2);
297 break;
298
299 case 2: //kilobytes
300 31 sprintf(num_str2,"%.2fk",float(number2)/1024);
301 31 break;
302
303 case 3: //megabytes
304 403 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
305 403 break;
306
307 case 4: //gigabytes
308 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
309 break;
310
311 default:
312 exit(1);
313 break;
314 }
315
316 434 sprintf(num_str, "%s/%s", num_str1, num_str2);
317 434 return num_str;
318 }
319
320 char *ordinal(int32_t num)
321 {
322 static const char *ending[4] = {"st","nd","rd","th"};
323 static char ord_str[8];
324
325 char *end;
326 int32_t t=(num%100)/10;
327 int32_t n=num%10;
328
329 if(n>=1 && n<4 && t!=1)
330 end = (char *)ending[n-1];
331 else
332 end = (char *)ending[3];
333
334 sprintf(ord_str,"%d%s",num%10000,end);
335 return ord_str;
336 }
337
338 31 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
339 {
340 int32_t ret;
341 31 *version=0;
342 31 *build=0;
343 31 byte temp_map_count=map_count;
344 byte temp_midi_flags[MIDIFLAGS_SIZE];
345 31 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
346
347 zquestheader tempheader;
348
349
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!f)
350 {
351 return qe_invalid;
352 }
353
354 31 ret=readheader(f, &tempheader, true);
355
356
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(ret)
357 {
358 return ret;
359 }
360
361 31 map_count=temp_map_count;
362 31 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
363 31 *version=tempheader.zelda_version;
364 31 *build=tempheader.build;
365 31 return 0;
366 31 }
367
368
369 31 bool find_section(PACKFILE *f, int32_t section_id_requested)
370 {
371
372
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!f)
373 {
374 return false;
375 }
376
377 int32_t section_id_read;
378 31 bool catchup=false;
379 word dummy;
380 byte tempbyte;
381 char tempbuf[65536];
382
383
384
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 switch(section_id_requested)
385 {
386 case ID_RULES:
387 case ID_STRINGS:
388 case ID_MISC:
389 case ID_TILES:
390 case ID_COMBOS:
391 case ID_CSETS:
392 case ID_MAPS:
393 case ID_DMAPS:
394 case ID_DOORS:
395 case ID_ITEMS:
396 case ID_WEAPONS:
397 case ID_COLORS:
398 case ID_ICONS:
399 case ID_INITDATA:
400 case ID_GUYS:
401 case ID_MIDIS:
402 case ID_CHEATS:
403 31 break;
404
405 default:
406 al_trace("Bad section requested!\n");
407 return false;
408 break;
409 }
410
411 dword section_size;
412
413 //section id
414
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_mgetl(&section_id_read,f,true))
415 {
416 return false;
417 }
418
419
1/2
✓ Branch 0 taken 6324 times.
✗ Branch 1 not taken.
6324 while(!pack_feof(f))
420 {
421
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 6293 times.
6324 switch(section_id_read)
422 {
423 case ID_RULES:
424 case ID_STRINGS:
425 case ID_MISC:
426 case ID_TILES:
427 case ID_COMBOS:
428 case ID_CSETS:
429 case ID_MAPS:
430 case ID_DMAPS:
431 case ID_DOORS:
432 case ID_ITEMS:
433 case ID_WEAPONS:
434 case ID_COLORS:
435 case ID_ICONS:
436 case ID_INITDATA:
437 case ID_GUYS:
438 case ID_MIDIS:
439 case ID_CHEATS:
440 31 catchup=false;
441 31 break;
442
443 default:
444 6293 break;
445 }
446
447
448
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6324 times.
6324 while(catchup)
449 {
450 //section id
451 section_id_read=(section_id_read<<8);
452
453 if(!p_getc(&tempbyte,f,true))
454 {
455 return false;
456 }
457
458 section_id_read+=tempbyte;
459 }
460
461
1/2
✓ Branch 0 taken 6324 times.
✗ Branch 1 not taken.
6324 if(section_id_read==section_id_requested)
462 {
463 return true;
464 }
465 else
466 {
467 //section version info
468
1/2
✓ Branch 0 taken 6324 times.
✗ Branch 1 not taken.
6324 if(!p_igetw(&dummy,f,true))
469 {
470 return false;
471 }
472
473
1/2
✓ Branch 0 taken 6324 times.
✗ Branch 1 not taken.
6324 if(!p_igetw(&dummy,f,true))
474 {
475 return false;
476 }
477
478 //section size
479
1/2
✓ Branch 0 taken 6324 times.
✗ Branch 1 not taken.
6324 if(!p_igetl(&section_size,f,true))
480 {
481 return false;
482 }
483
484 //pack_fseek(f, section_size);
485
2/2
✓ Branch 0 taken 2031585 times.
✓ Branch 1 taken 6324 times.
2037909 while(section_size>65535)
486 {
487 2031585 pfread(tempbuf,65535,f,true);
488 2031585 tempbuf[65535]=0;
489 2031585 section_size-=65535;
490 }
491
492
2/2
✓ Branch 0 taken 6169 times.
✓ Branch 1 taken 155 times.
6324 if(section_size>0)
493 {
494 155 pfread(tempbuf,section_size,f,true);
495 155 tempbuf[section_size]=0;
496 155 }
497 }
498
499 //section id
500
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 6293 times.
6324 if(!p_mgetl(&section_id_read,f,true))
501 {
502 31 return false;
503 }
504 }
505
506 return false;
507 31 }
508
509
510
511
512
513 31 bool valid_zqt(PACKFILE *f)
514 {
515
516 //word tiles_used;
517 //word combos_used;
518 //open the file
519 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!f)
521 return false;
522
523 //for now, everything else is valid
524 31 return true;
525
526 /*int16_t version;
527 byte build;
528
529 //read the version and make sure it worked
530 if(!p_igetw(&version,f,true))
531 {
532 goto error;
533 }
534
535 //read the build and make sure it worked
536 if(!p_getc(&build,f,true))
537 goto error;
538
539 //read the tile info and make sure it worked
540 if(!p_igetw(&tiles_used,f,true))
541 {
542 goto error;
543 }
544
545 for (int32_t i=0; i<tiles_used; i++)
546 {
547 if(!pfread(trashbuf,tilesize(tf4Bit),f,true))
548 {
549 goto error;
550 }
551 }
552
553 //read the combo info and make sure it worked
554 if(!p_igetw(&combos_used,f,true))
555 {
556 goto error;
557 }
558 for (int32_t i=0; i<combos_used; i++)
559 {
560 if(!pfread(trashbuf,sizeof(newcombo),f,true))
561 {
562 goto error;
563 }
564 }
565
566 //read the palette info and make sure it worked
567 for (int32_t i=0; i<48; i++)
568 {
569 if(!pfread(trashbuf,newpdTOTAL,f,true))
570 {
571 goto error;
572 }
573 }
574 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f,true))
575 {
576 goto error;
577 }
578 for (int32_t i=0; i<MAXLEVELS; i++)
579 {
580 if(!pfread(trashbuf,PALNAMESIZE,f,true))
581 {
582 goto error;
583 }
584 }
585
586 //read the sprite info and make sure it worked
587 for (int32_t i=0; i<MAXITEMS; i++)
588 {
589 if(!pfread(trashbuf,sizeof(itemdata),f,true))
590 {
591 goto error;
592 }
593 }
594
595 for (int32_t i=0; i<MAXWPNS; i++)
596 {
597 if(!pfread(trashbuf,sizeof(wpndata),f,true))
598 {
599 goto error;
600 }
601 }
602
603 //read the triforce pieces info and make sure it worked
604 for (int32_t i=0; i<8; ++i)
605 {
606 if(!p_getc(&trashbuf,f,true))
607 {
608 goto error;
609 }
610 }
611
612
613
614 //read the game icons info and make sure it worked
615 for (int32_t i=0; i<4; ++i)
616 {
617 if(!p_igetw(&trashbuf,f,true))
618 {
619 goto error;
620 }
621 }
622
623 //read the misc colors info and map styles info and make sure it worked
624 if(!pfread(trashbuf,sizeof(zcolors),f,true))
625 {
626 goto error;
627 }
628
629 //read the template screens and make sure it worked
630 byte num_maps;
631 if(!p_getc(&num_maps,f,true))
632 {
633 goto error;
634 }
635 for (int32_t i=0; i<TEMPLATES; i++)
636 {
637 if(!pfread(trashbuf,sizeof(mapscr),f,true))
638 {
639 goto error;
640 }
641 }
642 if (num_maps>1) //dungeon templates
643 {
644 for (int32_t i=0; i<TEMPLATES; i++)
645 {
646 if(!pfread(trashbuf,sizeof(mapscr),f,true))
647 {
648 goto error;
649 }
650 }
651 }
652
653 //yay! it worked! close the file and say everything was ok.
654 pack_fclose(f);
655 return true;
656
657 error:
658 pack_fclose(f);
659 return false;*/
660 31 }
661
662 bool valid_zqt(const char *filename)
663 {
664 PACKFILE *f=NULL;
665 bool isvalid;
666 char deletefilename[1024];
667 deletefilename[0]=0;
668 int32_t error;
669 f=open_quest_file(&error, filename, deletefilename, true, true,false);
670
671 if(!f)
672 {
673 // setPackfilePassword(NULL);
674 return false;
675 }
676
677 isvalid=valid_zqt(f);
678
679 if(deletefilename[0])
680 {
681 delete_file(deletefilename);
682 }
683
684 // setPackfilePassword(NULL);
685 return isvalid;
686 }
687
688 135 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, char *deletefilename, bool compressed,bool encrypted, bool show_progress)
689 {
690 char tmpfilename[L_tmpnam];
691 135 temp_name(tmpfilename);
692 char percent_done[30];
693 135 int32_t current_method=0;
694
695 PACKFILE *f;
696 135 const char *passwd= encrypted ? datapwd : "";
697
698 // oldquest flag is set when an unencrypted qst file is suspected.
699 135 bool oldquest = false;
700 int32_t ret;
701
702
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(show_progress)
703 {
704 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
705 }
706
707 135 box_out("Loading Quest: ");
708 //if(strncasecmp(filename, "qst.dat", 7)!=0)
709 //int32_t qstdat_str_size = 0;
710 //for ( int32_t q = 0; q < 255; q++ ) //find the length of the string
711 //{
712 // if ( moduledata.datafiles[qst_dat][q] != 0 ) qstdat_str_size++;
713 // else break;
714 //}
715 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], 7)!=0)
716 135 al_trace("Trying to do strncasecmp() when loading a quest\n");
717 135 int32_t qstdat_filename_size = strlen(moduledata.datafiles[qst_dat]);
718 135 al_trace("Filename size of qst.dat file %s is %d.\n", moduledata.datafiles[qst_dat], qstdat_filename_size);
719 //if(strncasecmp(filename, moduledata.datafiles[qst_dat], qstdat_filename_size)!=0)
720
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(strcmp(filename, moduledata.datafiles[qst_dat])!=0)
721 {
722 135 box_out(filename);
723 135 }
724 else
725 {
726 box_out("new quest"); // Or whatever
727 }
728 135 box_out("...");
729 135 box_eol();
730 135 box_eol();
731
732
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(encrypted)
733 {
734 135 box_out("Decrypting...");
735 135 box_save_x();
736 135 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, strstr(filename, ".dat#")!=NULL, passwd);
737
738
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 7 times.
135 if(ret)
739 {
740
1/3
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7 switch(ret)
741 {
742 case 1:
743 box_out("error.");
744 box_eol();
745 box_end(true);
746 *open_error=qe_notfound;
747 return NULL;
748
749 case 2:
750 box_out("error.");
751 box_eol();
752 box_end(true);
753 *open_error=qe_internal;
754 return NULL;
755 // be sure not to delete tmpfilename now...
756 }
757
758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(ret==5) //old encryption?
759 {
760 7 current_method++;
761 7 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
762 7 box_out(percent_done);
763 7 box_load_x();
764 7 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
765 7 }
766
767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(ret==5) //old encryption?
768 {
769 7 current_method++;
770 7 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
771 7 box_out(percent_done);
772 7 box_load_x();
773 7 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
774 7 }
775
776
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(ret==5) //old encryption?
777 {
778 2 current_method++;
779 2 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
780 2 box_out(percent_done);
781 2 box_load_x();
782 2 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
783 2 }
784
785
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(ret==5) //old encryption?
786 {
787 2 current_method++;
788 2 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
789 2 box_out(percent_done);
790 2 box_load_x();
791 2 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
792 2 }
793
794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(ret)
795 {
796 oldquest = true;
797 passwd="";
798 }
799 7 }
800
801 135 box_out("okay.");
802 135 box_eol();
803 135 }
804 else
805 {
806 oldquest = true;
807 }
808
809 135 box_out("Opening...");
810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
811
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!f)
812 {
813 if((compressed==1)&&(errno==EDOM))
814 {
815 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
816 }
817
818 if(!f)
819 {
820 if(!oldquest)
821 {
822 delete_file(tmpfilename);
823 }
824 box_out("error.");
825 box_eol();
826 box_end(true);
827 *open_error=qe_invalid;
828 return NULL;
829 }
830 }
831
832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(!oldquest)
833 {
834
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(deletefilename)
835 135 sprintf(deletefilename, "%s", tmpfilename);
836 135 }
837
838 135 box_out("okay.");
839 135 box_eol();
840
841 135 return f;
842 135 }
843
844 31 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
845 {
846 char *filename;
847 31 PACKFILE *f=NULL;
848 31 int32_t open_error=0;
849 31 deletefilename[0]=0;
850
851 31 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
852 31 strcat(qstdat_string,"#NESQST_NEW_QST");
853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(Header->templatepath[0]==0)
854 {
855 31 filename=(char *)malloc(2048);
856 //strcpy(filename, "qst.dat#NESQST_NEW_QST");
857 31 strcpy(filename, qstdat_string);
858 31 }
859 else
860 {
861 filename=Header->templatepath;
862 }
863
864 31 f=open_quest_file(&open_error, filename, deletefilename, true, true,false);
865
866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(Header->templatepath[0]==0)
867 {
868 31 free(filename);
869 31 }
870
871
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!f)
872 {
873 return NULL;
874 }
875
876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(validate)
877 {
878
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!valid_zqt(f))
879 {
880 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
881 pack_fclose(f);
882
883 //setPackfilePassword(NULL);
884 if(deletefilename[0])
885 {
886 delete_file(deletefilename);
887 }
888
889 return NULL;
890 }
891 31 }
892
893 31 return f;
894 31 }
895
896 31 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
897 {
898 31 combosread=false;
899 31 mapsread=false;
900 31 fixffcs=false;
901
902
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 switch(section_id)
903 {
904 case ID_RULES:
905 case ID_STRINGS:
906 case ID_MISC:
907 case ID_TILES:
908 case ID_COMBOS:
909 case ID_CSETS:
910 case ID_MAPS:
911 case ID_DMAPS:
912 case ID_DOORS:
913 case ID_ITEMS:
914 case ID_WEAPONS:
915 case ID_COLORS:
916 case ID_ICONS:
917 case ID_INITDATA:
918 case ID_GUYS:
919 case ID_MIDIS:
920 case ID_CHEATS:
921 case ID_ITEMDROPSETS:
922 case ID_FAVORITES:
923 31 break;
924
925 default:
926 return false;
927 break;
928 }
929
930 int32_t ret;
931 word version, build;
932 31 PACKFILE *f=NULL;
933
934 char deletefilename[1024];
935 31 deletefilename[0]=0;
936
937 //why is this here?
938 /*
939 if(colordata==NULL)
940 return false;
941 */
942
943 //setPackfilePassword(datapwd);
944 31 f=open_quest_template(Header, deletefilename, validate);
945
946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!f) //no file, nothing to delete
947 {
948 // setPackfilePassword(NULL);
949 return false;
950 }
951
952 31 ret=get_version_and_build(f, &version, &build);
953
954
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 if(ret||(version==0))
955 {
956 pack_fclose(f);
957
958 if(deletefilename[0])
959 {
960 delete_file(deletefilename);
961 }
962
963 // setPackfilePassword(NULL);
964 return false;
965 }
966
967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(!find_section(f, section_id))
968 {
969 31 al_trace("Can't find section!\n");
970 31 pack_fclose(f);
971
972
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(deletefilename[0])
973 {
974 31 delete_file(deletefilename);
975 31 }
976
977 //setPackfilePassword(NULL);
978 31 return false;
979 }
980
981 switch(section_id)
982 {
983 case ID_RULES:
984 //rules
985 ret=readrules(f, Header, true);
986 break;
987
988 case ID_STRINGS:
989 //strings
990 ret=readstrings(f, Header, true);
991 break;
992
993 case ID_MISC:
994 //misc data
995 ret=readmisc(f, Header, Misc, true);
996 break;
997
998 case ID_TILES:
999 //tiles
1000 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true, true);
1001 break;
1002
1003 case ID_COMBOS:
1004 //combos
1005 clear_combos();
1006 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS, true);
1007 combosread=true;
1008 break;
1009
1010 case ID_COMBOALIASES:
1011 //combos
1012 ret=readcomboaliases(f, Header, version, build, true);
1013 break;
1014
1015 case ID_CSETS:
1016 //color data
1017 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL, true);
1018 break;
1019
1020 case ID_MAPS:
1021 //maps
1022 ret=readmaps(f, Header, true);
1023 mapsread=true;
1024 break;
1025
1026 case ID_DMAPS:
1027 //dmaps
1028 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS, true);
1029 break;
1030
1031 case ID_DOORS:
1032 //door combo sets
1033 ret=readdoorcombosets(f, Header, true);
1034 break;
1035
1036 case ID_ITEMS:
1037 //items
1038 ret=readitems(f, version, build, true);
1039 break;
1040
1041 case ID_WEAPONS:
1042 //weapons
1043 ret=readweapons(f, Header, true);
1044 break;
1045
1046 case ID_COLORS:
1047 //misc. colors
1048 ret=readmisccolors(f, Header, Misc, true);
1049 break;
1050
1051 case ID_ICONS:
1052 //game icons
1053 ret=readgameicons(f, Header, Misc, true);
1054 break;
1055
1056 case ID_INITDATA:
1057 //initialization data
1058 ret=readinitdata(f, Header, true);
1059 break;
1060
1061 case ID_GUYS:
1062 //guys
1063 ret=readguys(f, Header, true);
1064 break;
1065
1066 case ID_MIDIS:
1067 //midis
1068 ret=readtunes(f, Header, tunes, true);
1069 break;
1070
1071 case ID_CHEATS:
1072 //cheat codes
1073 ret=readcheatcodes(f, Header, true);
1074 break;
1075
1076 case ID_ITEMDROPSETS:
1077 //item drop sets
1078 // Why is this one commented out?
1079 //ret=readitemdropsets(f, (int32_t)version, (word)build, true);
1080 break;
1081
1082 case ID_FAVORITES:
1083 // favorite combos and aliases
1084 ret=readfavorites(f, version, build, true);
1085 break;
1086
1087 default:
1088 ret=-1;
1089 break;
1090 }
1091
1092 pack_fclose(f);
1093
1094 if(deletefilename[0])
1095 {
1096 delete_file(deletefilename);
1097 }
1098
1099 //setPackfilePassword(NULL);
1100 if(!ret)
1101 {
1102 return true;
1103 }
1104
1105 return false;
1106 31 }
1107
1108 bool init_tiles(bool validate, zquestheader *Header)
1109 {
1110 return init_section(Header, ID_TILES, NULL, NULL, validate);
1111 }
1112
1113 bool init_combos(bool validate, zquestheader *Header)
1114 {
1115 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1116 }
1117
1118 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1119 {
1120 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1121 }
1122
1123 104 void init_spritelists()
1124 {
1125
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(FFCore.quest_format[vZelda] < 0x255)
1126 {
1127 81 guys.setMax(255);
1128 81 items.setMax(255);
1129 81 Ewpns.setMax(255);
1130 81 Lwpns.setMax(255);
1131 81 Sitems.setMax(255);
1132 81 chainlinks.setMax(255);
1133 81 decorations.setMax(255);
1134 81 particles.setMax(255);
1135 81 }
1136 else
1137 {
1138 23 guys.setMax(255);
1139 23 items.setMax(255);
1140 23 Ewpns.setMax(255);
1141 23 Lwpns.setMax(255);
1142 23 Sitems.setMax(255);
1143 23 chainlinks.setMax(255);
1144 23 decorations.setMax(255);
1145 23 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1146 }
1147 104 }
1148
1149 31 bool reset_items(bool validate, zquestheader *Header)
1150 {
1151 31 bool ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1152
1153 //Ignore this, but don't remove it
1154 /*
1155 if (ret)
1156 for(int32_t i=0; i<MAXITEMS; i++)
1157 {
1158 reset_itembuf(&itemsbuf[i], i);
1159 }
1160 */
1161
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 31 times.
7967 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1162
1163 31 return ret;
1164 }
1165
1166 bool reset_guys()
1167 {
1168 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1169 init_guys(V_GUYS);
1170 return true;
1171 }
1172
1173 bool reset_wpns(bool validate, zquestheader *Header)
1174 {
1175 bool ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1176
1177 for(int32_t i=0; i<WPNCNT; i++)
1178 reset_weaponname(i);
1179
1180 return ret;
1181 }
1182
1183 bool reset_mapstyles(bool validate, miscQdata *Misc)
1184 {
1185 Misc->colors.blueframe_tile = 20044;
1186 Misc->colors.blueframe_cset = 0;
1187 Misc->colors.triforce_tile = 23461;
1188 Misc->colors.triforce_cset = 1;
1189 Misc->colors.triframe_tile = 18752;
1190 Misc->colors.triframe_cset = 1;
1191 Misc->colors.overworld_map_tile = 16990;
1192 Misc->colors.overworld_map_cset = 2;
1193 Misc->colors.HCpieces_tile = 21160;
1194 Misc->colors.HCpieces_cset = 8;
1195 Misc->colors.dungeon_map_tile = 19651;
1196 Misc->colors.dungeon_map_cset = 8;
1197 return true;
1198 }
1199
1200 bool reset_doorcombosets(bool validate, zquestheader *Header)
1201 {
1202 return init_section(Header, ID_DOORS, NULL, NULL, validate);
1203 }
1204
1205 31 int32_t get_qst_buffers()
1206 {
1207 31 memrequested+=(sizeof(mapscr)*MAPSCRS);
1208 31 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1209 31 TheMaps.resize(MAPSCRS);
1210
1211
2/2
✓ Branch 0 taken 4216 times.
✓ Branch 1 taken 31 times.
4247 for(int32_t i(0); i<MAPSCRS; i++)
1212 4216 TheMaps[i].zero_memory();
1213
1214 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1215 31 Z_message("OK\n"); // Allocating map buffer...
1216
1217 31 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1218 31 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1219
1220
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1221 return 0;
1222
1223 31 Z_message("OK\n");
1224
1225 // Allocating space for all 65535 strings uses up 10.62MB...
1226 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1227 // (Shoelace's "Hero of Dreams" uses 1415.)
1228 // So let's be a bit generous and allow 4096 initially.
1229 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1230 // I tested it and it worked without flaw on 6/6/11. - L.
1231 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1232 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1233 // See https://discord.com/channels/876899628556091432/992984989073416242
1234 31 msg_strings_size = 8192;
1235 31 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1236 31 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1237
1238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 MsgStrings = new MsgStr[msg_strings_size];
1239
1240 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1241
2/2
✓ Branch 0 taken 253952 times.
✓ Branch 1 taken 31 times.
253983 for(auto q = 0; q < msg_strings_size; ++q)
1242 {
1243 253952 MsgStrings[q].clear();
1244 253952 }
1245 31 Z_message("OK\n"); // Allocating string buffer...
1246
1247 31 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1248 31 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1249
1250
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1251 return 0;
1252
1253 31 Z_message("OK\n"); // Allocating door combo buffer...
1254
1255 31 memrequested+=(sizeof(dmap)*MAXDMAPS);
1256 31 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1257
1258
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1259 return 0;
1260
1261 31 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1262 31 Z_message("OK\n"); // Allocating dmap buffer...
1263
1264 31 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1265 31 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1266
1267
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((combobuf=(newcombo*)malloc(sizeof(newcombo)*MAXCOMBOS))==NULL)
1268 return 0;
1269
1270 31 memset(combobuf, 0, sizeof(newcombo)*MAXCOMBOS);
1271 31 Z_message("OK\n"); // Allocating combo buffer...
1272
1273 31 memrequested+=(psTOTAL255);
1274 31 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1275
1276
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1277 return 0;
1278
1279 31 Z_message("OK\n"); // Allocating color data buffer...
1280
1281 31 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1282 31 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1283
1284 31 free_newtilebuf();
1285
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1286 return 0;
1287
1288 31 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1289 //Z_message("Performed memset on tiles\n");
1290 31 clear_tiles(newtilebuf);
1291 //Z_message("Performed clear_tiles()\n");
1292 31 Z_message("OK\n"); // Allocating tile buffer...
1293
1294
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(is_zquest())
1295 {
1296 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1297 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1298
1299 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1300 return 0;
1301
1302 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1303 clear_tiles(grabtilebuf);
1304 Z_message("OK\n"); // Allocating tile grab buffer...
1305 }
1306
1307 31 memrequested+=(100000);
1308 31 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1309
1310
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((trashbuf=(byte*)malloc(100000))==NULL)
1311 return 0;
1312
1313 31 Z_message("OK\n"); // Allocating trash buffer...
1314
1315 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1316 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1317 // fixed by ensuring there's actually itemdata there.
1318 // If you change this, be sure to update del_qst_buffers, too.
1319
1320 31 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1321 31 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1322
1323
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1324 return 0;
1325
1326 31 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1327 31 itemsbuf++;
1328 31 Z_message("OK\n"); // Allocating item buffer...
1329
1330 31 memrequested+=(sizeof(wpndata)*MAXWPNS);
1331 31 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1332
1333
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1334 return 0;
1335
1336 31 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1337 31 Z_message("OK\n"); // Allocating weapon buffer...
1338
1339 31 memrequested+=(sizeof(guydata)*MAXGUYS);
1340 31 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1341
1342
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1343 return 0;
1344
1345 31 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1346 31 Z_message("OK\n"); // Allocating guy buffer...
1347
1348 31 memrequested+=(sizeof(comboclass)*cMAX);
1349 31 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1350
1351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1352 return 0;
1353
1354 31 Z_message("OK\n"); // Allocating combo class buffer...
1355
1356 31 return 1;
1357 31 }
1358
1359
1360 31 void free_newtilebuf()
1361 {
1362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(newtilebuf)
1363 {
1364 for(int32_t i=0; i<NEWMAXTILES; i++)
1365 if(newtilebuf[i].data)
1366 free(newtilebuf[i].data);
1367
1368 free(newtilebuf);
1369 newtilebuf = 0;
1370 }
1371 31 }
1372
1373 void free_grabtilebuf()
1374 {
1375 if(is_zquest())
1376 {
1377 if(grabtilebuf)
1378 {
1379 for(int32_t i=0; i<NEWMAXTILES; i++)
1380 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1381
1382 free(grabtilebuf);
1383 grabtilebuf = 0;
1384 }
1385 }
1386 }
1387
1388 void del_qst_buffers()
1389 {
1390 al_trace("Cleaning maps. \n");
1391
1392 if(ZCMaps) free(ZCMaps);
1393
1394 if(MsgStrings) delete[] MsgStrings;
1395
1396 if(DoorComboSets) free(DoorComboSets);
1397
1398 if(DMaps) free(DMaps);
1399
1400 if(combobuf) free(combobuf);
1401
1402 if(colordata) free(colordata);
1403
1404 al_trace("Cleaning tile buffers. \n");
1405 free_newtilebuf();
1406 free_grabtilebuf();
1407
1408 al_trace("Cleaning misc. \n");
1409
1410 if(trashbuf) free(trashbuf);
1411
1412 // See get_qst_buffers
1413 if(itemsbuf)
1414 {
1415 itemsbuf--;
1416 free(itemsbuf);
1417 }
1418
1419 if(wpnsbuf) free(wpnsbuf);
1420
1421 if(guysbuf) free(guysbuf);
1422
1423 if(combo_class_buf) free(combo_class_buf);
1424 }
1425
1426 2 bool init_palnames()
1427 {
1428 // if(palnames==NULL)
1429 // return false;
1430
1431
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
1026 for(int32_t x=0; x<MAXLEVELS; x++)
1432 {
1433
4/4
✓ Branch 0 taken 1018 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
1024 switch(x)
1434 {
1435 case 0:
1436 2 sprintf(palnames[x],"Overworld");
1437 2 break;
1438
1439 case 10:
1440 2 sprintf(palnames[x],"Caves");
1441 2 break;
1442
1443 case 11:
1444 2 sprintf(palnames[x],"Passageways");
1445 2 break;
1446
1447 default:
1448 1018 sprintf(palnames[x],"%c",0);
1449 1018 break;
1450 }
1451 1024 }
1452
1453 2 return true;
1454 }
1455
1456 20291 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size, bool keepdata)
1457 {
1458 void *p;
1459
1460
1/2
✓ Branch 0 taken 20291 times.
✗ Branch 1 not taken.
20291 p = _AL_MALLOC(MAX(size, alloc_size));
1461
1462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20291 times.
20291 if(!p)
1463 {
1464 return NULL;
1465 }
1466
1467
1/2
✓ Branch 0 taken 20291 times.
✗ Branch 1 not taken.
20291 if(!pfread(p,size,f,keepdata))
1468 {
1469 _AL_FREE(p);
1470 return NULL;
1471 }
1472
1473
1/2
✓ Branch 0 taken 20291 times.
✗ Branch 1 not taken.
20291 if(pack_ferror(f))
1474 {
1475 _AL_FREE(p);
1476 return NULL;
1477 }
1478
1479 20291 return p;
1480 20291 }
1481
1482 /* read_midi:
1483 * Reads MIDI data from a datafile (this is not the same thing as the
1484 * standard midi file format).
1485 */
1486
1487 1778 static MIDI *read_midi(PACKFILE *f, bool)
1488 {
1489 MIDI *m;
1490 int32_t c;
1491 1778 int16_t divisions=0;
1492 1778 int32_t len=0;
1493
1494 1778 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1495
1496
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!m)
1497 {
1498 return NULL;
1499 }
1500
1501
2/2
✓ Branch 0 taken 56896 times.
✓ Branch 1 taken 1778 times.
58674 for(c=0; c<MIDI_TRACKS; c++)
1502 {
1503 56896 m->track[c].len = 0;
1504 56896 m->track[c].data = NULL;
1505 56896 }
1506
1507 1778 p_mgetw(&divisions,f,true);
1508 1778 m->divisions=divisions;
1509
1510
2/2
✓ Branch 0 taken 56896 times.
✓ Branch 1 taken 1778 times.
58674 for(c=0; c<MIDI_TRACKS; c++)
1511 {
1512 56896 p_mgetl(&len,f,true);
1513 56896 m->track[c].len=len;
1514
1515
2/2
✓ Branch 0 taken 36605 times.
✓ Branch 1 taken 20291 times.
56896 if(m->track[c].len > 0)
1516 {
1517 20291 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0, true);
1518
1519
1/2
✓ Branch 0 taken 20291 times.
✗ Branch 1 not taken.
20291 if(!m->track[c].data)
1520 {
1521 destroy_midi(m);
1522 return NULL;
1523 }
1524 20291 }
1525 56896 }
1526
1527 LOCK_DATA(m, sizeof(MIDI));
1528
1529
2/2
✓ Branch 0 taken 56896 times.
✓ Branch 1 taken 1778 times.
58674 for(c=0; c<MIDI_TRACKS; c++)
1530 {
1531
2/2
✓ Branch 0 taken 20291 times.
✓ Branch 1 taken 36605 times.
56896 if(m->track[c].data)
1532 {
1533 LOCK_DATA(m->track[c].data, m->track[c].len);
1534 20291 }
1535 56896 }
1536
1537 1778 return m;
1538 1778 }
1539
1540 void clear_combo(int32_t i)
1541 {
1542 combobuf[i].clear();
1543 }
1544
1545 void clear_combos()
1546 {
1547 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1548 clear_combo(tmpcounter);
1549 }
1550
1551 void pack_combos()
1552 {
1553 int32_t di = 0;
1554
1555 for(int32_t si=0; si<1024; si+=2)
1556 combobuf[di++] = combobuf[si];
1557
1558 for(; di<1024; di++)
1559 clear_combo(di);
1560 }
1561
1562 104 void reset_tunes(zctune *tune)
1563 {
1564
2/2
✓ Branch 0 taken 26208 times.
✓ Branch 1 taken 104 times.
26312 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1565 {
1566 26208 tune[i].reset();
1567 26208 }
1568 104 }
1569
1570
1571 /*void reset_midi(zcmidi_ *m)
1572 {
1573 m->title[0]=0;
1574 m->loop=1;
1575 m->volume=144;
1576 m->start=0;
1577 m->loop_start=-1;
1578 m->loop_end=-1;
1579 if(m->midi)
1580 {
1581 destroy_midi(m->midi);
1582 }
1583 m->midi=NULL;
1584 }
1585
1586
1587 void reset_midis(zcmidi_ *m)
1588 {
1589 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1590 {
1591 reset_midi(m+i);
1592 }
1593 }
1594 */
1595
1596 void reset_scr(int32_t scr)
1597 {
1598 /*
1599 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1600 for(unsigned i=0; i<sizeof(mapscr); i++)
1601 *(di++) = 0;
1602 TheMaps[scr].valid=mVERSION;
1603 */
1604
1605 TheMaps[scr].zero_memory();
1606 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1607
1608 for(int32_t i=0; i<6; i++)
1609 {
1610 //these will be uncommented later
1611 //TheMaps[scr].layerxsize[i]=16;
1612 //TheMaps[scr].layerysize[i]=11;
1613 TheMaps[scr].layeropacity[i]=255;
1614 }
1615
1616 TheMaps[scr].valid=mVERSION;
1617
1618 }
1619
1620 /* For reference:
1621
1622 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1623 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1624 */
1625
1626 1011 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1627 {
1628
2/2
✓ Branch 0 taken 9099 times.
✓ Branch 1 taken 1011 times.
10110 for(int32_t i=0; i<9; i++)
1629 {
1630
2/2
✓ Branch 0 taken 54594 times.
✓ Branch 1 taken 9099 times.
63693 for(int32_t j=0; j<6; j++)
1631 {
1632
2/2
✓ Branch 0 taken 18198 times.
✓ Branch 1 taken 36396 times.
54594 if(j<4)
1633 {
1634
1/2
✓ Branch 0 taken 36396 times.
✗ Branch 1 not taken.
36396 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1635 {
1636 return false;
1637 }
1638
1639
1/2
✓ Branch 0 taken 36396 times.
✗ Branch 1 not taken.
36396 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1640 {
1641 return false;
1642 }
1643
1644
1/2
✓ Branch 0 taken 36396 times.
✗ Branch 1 not taken.
36396 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1645 {
1646 return false;
1647 }
1648
1649
1/2
✓ Branch 0 taken 36396 times.
✗ Branch 1 not taken.
36396 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1650 {
1651 return false;
1652 }
1653 36396 }
1654
1655
1/2
✓ Branch 0 taken 54594 times.
✗ Branch 1 not taken.
54594 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1656 {
1657 return false;
1658 }
1659
1660
1/2
✓ Branch 0 taken 54594 times.
✗ Branch 1 not taken.
54594 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1661 {
1662 return false;
1663 }
1664
1665
1/2
✓ Branch 0 taken 54594 times.
✗ Branch 1 not taken.
54594 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1666 {
1667 return false;
1668 }
1669
1670
1/2
✓ Branch 0 taken 54594 times.
✗ Branch 1 not taken.
54594 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1671 {
1672 return false;
1673 }
1674 54594 }
1675
1676
2/2
✓ Branch 0 taken 7077 times.
✓ Branch 1 taken 2022 times.
9099 if(i<2)
1677 {
1678
1/2
✓ Branch 0 taken 2022 times.
✗ Branch 1 not taken.
2022 if(a.flags[i]!=b.flags[i])
1679 {
1680 return false;
1681 }
1682
1683
1/2
✓ Branch 0 taken 2022 times.
✗ Branch 1 not taken.
2022 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1684 {
1685 return false;
1686 }
1687
1688
1/2
✓ Branch 0 taken 2022 times.
✗ Branch 1 not taken.
2022 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1689 {
1690 return false;
1691 }
1692
1693
1/2
✓ Branch 0 taken 2022 times.
✗ Branch 1 not taken.
2022 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1694 {
1695 return false;
1696 }
1697
1698
1/2
✓ Branch 0 taken 2022 times.
✗ Branch 1 not taken.
2022 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1699 {
1700 return false;
1701 }
1702 2022 }
1703
1704
2/2
✓ Branch 0 taken 6066 times.
✓ Branch 1 taken 3033 times.
9099 if(i<3)
1705 {
1706
1/2
✓ Branch 0 taken 3033 times.
✗ Branch 1 not taken.
3033 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1707 {
1708 return false;
1709 }
1710
1711
1/2
✓ Branch 0 taken 3033 times.
✗ Branch 1 not taken.
3033 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1712 {
1713 return false;
1714 }
1715
1716
1/2
✓ Branch 0 taken 3033 times.
✗ Branch 1 not taken.
3033 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1717 {
1718 return false;
1719 }
1720
1721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3033 times.
3033 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1722 {
1723 return false;
1724 }
1725 3033 }
1726
1727
1/2
✓ Branch 0 taken 9099 times.
✗ Branch 1 not taken.
9099 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1728 {
1729 return false;
1730 }
1731
1732
1/2
✓ Branch 0 taken 9099 times.
✗ Branch 1 not taken.
9099 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1733 {
1734 return false;
1735 }
1736 9099 }
1737
1738 1011 return true;
1739 1011 }
1740
1741 int32_t doortranslations_u[9][4]=
1742 {
1743 {37,38,53,54},
1744 {37,38,39,40},
1745 {37,38,55,56},
1746 {37,38,39,40},
1747 {37,38,53,54},
1748 {37,38,53,54},
1749 {37,38,53,54},
1750 {7,8,23,24},
1751 {7,8,41,42}
1752 };
1753
1754 int32_t doortranslations_d[9][4]=
1755 {
1756 {117,118,133,134},
1757 {135,136,133,134},
1758 {119,120,133,134},
1759 {135,136,133,134},
1760 {117,118,133,134},
1761 {117,118,133,134},
1762 {117,118,133,134},
1763 {151,152,167,168},
1764 {137,138,167,168},
1765 };
1766
1767 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1768 int32_t doortranslations_l[9][6]=
1769 {
1770 {66,67,82,83,98,99},
1771 {66,68,82,84,98,100},
1772 {66,69,82,85,98,101},
1773 {66,68,82,84,98,100},
1774 {66,67,82,83,98,99},
1775 {66,67,82,83,98,99},
1776 {66,67,82,83,98,99},
1777 {64,65,80,81,96,97},
1778 {64,65,80,114,96,97},
1779 };
1780
1781 int32_t doortranslations_r[9][6]=
1782 {
1783
1784 {76,77,92,93,108,109},
1785 {75,77,91,93,107,109},
1786 {74,77,90,93,106,109},
1787 {75,77,91,93,107,109},
1788 {76,77,92,93,108,109},
1789 {76,77,92,93,108,109},
1790 {76,77,92,93,108,109},
1791 {78,79,94,95,110,111},
1792 {78,79,125,95,110,111},
1793 };
1794
1795 196328 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1796 {
1797 196328 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1798 }
1799
1800 192280 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1801 {
1802 //these are here to bypass compiler warnings about unused arguments
1803 192280 map=map;
1804 192280 scr=scr;
1805 192280 pos=pos;
1806
1807 //what does this function do?
1808 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1809 192280 return 2;
1810 }
1811
1812 3536 int32_t MakeDoors(int32_t map, int32_t scr)
1813 {
1814
2/2
✓ Branch 0 taken 2524 times.
✓ Branch 1 taken 1012 times.
3536 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1815 {
1816 2524 return 0;
1817 }
1818
1819 DoorComboSet tempdcs;
1820 1012 memset(&tempdcs, 0, sizeof(DoorComboSet));
1821
1822 //up
1823
2/2
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 1012 times.
10120 for(int32_t i=0; i<9; i++)
1824 {
1825
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9108 times.
45540 for(int32_t j=0; j<4; j++)
1826 {
1827 36432 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1828 36432 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1829 36432 }
1830 9108 }
1831
1832 1012 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1833 1012 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1834 1012 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1835 1012 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1836 1012 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1837 1012 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1838
1839 //down
1840
2/2
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 1012 times.
10120 for(int32_t i=0; i<9; i++)
1841 {
1842
2/2
✓ Branch 0 taken 36432 times.
✓ Branch 1 taken 9108 times.
45540 for(int32_t j=0; j<4; j++)
1843 {
1844 36432 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1845 36432 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1846 36432 }
1847 9108 }
1848
1849 1012 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1850
1851 1012 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1852 1012 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1853 1012 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1854 1012 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1855 1012 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1856
1857 //left
1858 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1859
2/2
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 1012 times.
10120 for(int32_t i=0; i<9; i++)
1860 {
1861
2/2
✓ Branch 0 taken 54648 times.
✓ Branch 1 taken 9108 times.
63756 for(int32_t j=0; j<6; j++)
1862 {
1863 54648 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1864 54648 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1865 54648 }
1866 9108 }
1867
1868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
1012 for(int32_t j=0; j>6; j++)
1869 {
1870 if((j!=2)&&(j!=3))
1871 {
1872 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1873 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1874 }
1875 }
1876
1877 1012 tempdcs.bombdoorcombo_l[0]=0;
1878 1012 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1879 1012 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1880 1012 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1881 1012 tempdcs.bombdoorcombo_l[2]=0;
1882 1012 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1883 1012 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1884 1012 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1885
1886 //right
1887
2/2
✓ Branch 0 taken 9108 times.
✓ Branch 1 taken 1012 times.
10120 for(int32_t i=0; i<9; i++)
1888 {
1889
2/2
✓ Branch 0 taken 54648 times.
✓ Branch 1 taken 9108 times.
63756 for(int32_t j=0; j<6; j++)
1890 {
1891 54648 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1892 54648 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1893 54648 }
1894 9108 }
1895
1896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1012 times.
1012 for(int32_t j=0; j>6; j++)
1897 {
1898 if((j!=2)&&(j!=3))
1899 {
1900 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1901 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1902 }
1903 }
1904
1905 1012 tempdcs.bombdoorcombo_r[0]=0;
1906 1012 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1907 1012 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1908 1012 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1909 1012 tempdcs.bombdoorcombo_r[2]=0;
1910 1012 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1911 1012 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1912 1012 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1913
1914 int32_t k;
1915
1916
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1011 times.
1012 for(k=0; k<door_combo_set_count; k++)
1917 {
1918
1/2
✓ Branch 0 taken 1011 times.
✗ Branch 1 not taken.
1011 if(DoorComboSets[k]==tempdcs)
1919 {
1920 1011 break;
1921 }
1922 }
1923
1924
2/2
✓ Branch 0 taken 1011 times.
✓ Branch 1 taken 1 times.
1012 if(k==door_combo_set_count)
1925 {
1926 1 DoorComboSets[k]=tempdcs;
1927 1 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1928 1 ++door_combo_set_count;
1929 1 }
1930
1931 1012 return k;
1932 /*
1933 doorcombo_u[9][4];
1934 doorcset_u[9][4];
1935 doorcombo_d[9][4];
1936 doorcset_d[9][4];
1937 doorcombo_l[9][6];
1938 doorcset_l[9][6];
1939 doorcombo_r[9][6];
1940 doorcset_r[9][6];
1941 bombdoorcombo_u[2];
1942 bombdoorcset_u[2];
1943 bombdoorcombo_d[2];
1944 bombdoorcset_d[2];
1945 bombdoorcombo_l[3];
1946 bombdoorcset_l[3];
1947 bombdoorcombo_r[3];
1948 bombdoorcset_r[3];
1949 walkthroughcombo[4];
1950 walkthroughcset[4];
1951 */
1952 3536 }
1953
1954 452608 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1955 {
1956 452608 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1957 }
1958
1959 452608 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1960 {
1961
1962 452608 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1963 }
1964
1965 452608 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1966 {
1967 452608 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1968 }
1969
1970
1971 7 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1972 {
1973 char temp_pwd[30];
1974 7 memset(temp_pwd,0,30);
1975
1976
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(pwdkey!=0)
1977 {
1978 7 memcpy(temp_pwd,encrypted_pwd,30);
1979 7 temp_pwd[29]=0;
1980
1981
2/2
✓ Branch 0 taken 210 times.
✓ Branch 1 taken 7 times.
217 for(int32_t i=0; i<30; i++)
1982 {
1983 210 temp_pwd[i] -= pwdkey;
1984 210 int32_t t=pwdkey>>15;
1985 210 pwdkey = (pwdkey<<1)+t;
1986 210 }
1987 7 }
1988
1989 7 memcpy(pwd,temp_pwd,30);
1990 7 }
1991
1992
1993 83 bool devpwd()
1994 {
1995 #ifdef _DEBUG
1996 return true;
1997 #endif
1998 83 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
1999 }
2000 bool check_questpwd(zquestheader *Header, char *pwd)
2001 {
2002 #if DEVLEVEL > 3
2003 return true;
2004 #endif
2005
2006 if (devpwd()) return true;
2007 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2008 cvs_MD5Context ctx;
2009 uint8_t md5sum[16];
2010
2011 cvs_MD5Init(&ctx);
2012 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2013 cvs_MD5Final(md5sum, &ctx);
2014
2015 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2016 }
2017
2018 98 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2019 {
2020 98 zprint2("\n");
2021 98 zprint2("[ZQUEST CREATOR METADATA]\n");
2022
1/2
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
98 if(qst_num < moduledata.max_quest_files)
2023 zprint2("Loading module quest %d\n", qst_num+1);
2024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(path) zprint2("Loading '%s'\n", path);
2025
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 2 times.
98 if ( tempheader.new_version_id_main > 0 )
2026 {
2027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(tempheader.new_version_id_fourth > 0)
2028 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2029 tempheader.new_version_id_main,tempheader.new_version_id_second,
2030 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2031 96 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2032 96 tempheader.new_version_id_main,tempheader.new_version_id_second,
2033 96 tempheader.new_version_id_third);
2034 96 }
2035 else
2036 {
2037
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
2 switch ( tempheader.zelda_version )
2038 {
2039 case 0x255:
2040 {
2041 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2042 break;
2043 }
2044 case 0x254:
2045 {
2046 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2047 break;
2048 }
2049 case 0x250:
2050 {
2051 switch(tempheader.build)
2052 {
2053 case 19:
2054 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2055 case 20:
2056 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2057 case 21:
2058 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2059 case 22:
2060 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2061 case 23:
2062 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2063 case 24:
2064 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2065 case 25:
2066 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2067 case 26:
2068 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2069 case 27:
2070 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2071 case 28:
2072 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2073 case 29:
2074 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2075 case 30:
2076 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2077 case 31:
2078 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2079 case 32:
2080 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2081 case 33:
2082 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2083 default:
2084 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2085
2086 }
2087 break;
2088 }
2089
2090 case 0x211:
2091 {
2092 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2093 }
2094 case 0x210:
2095 {
2096 zprint2("Last saved in ZQuest Version: 2.10.x");
2097 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2098 break;
2099 }
2100 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2101 case 0x193:
2102 {
2103 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2104 }
2105 case 0x192:
2106 {
2107 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2108 }
2109 case 0x190:
2110 {
2111 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2112 }
2113 case 0x184:
2114 {
2115 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2116 }
2117 case 0x183:
2118 {
2119 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2120 }
2121 case 0x180:
2122 {
2123 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2124 }
2125 default:
2126 {
2127 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2128 }
2129 */
2130 }
2131 }
2132
3/4
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 17 times.
98 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2133 17 zprint2("%s\n", tempheader.getAlphaVerStr());
2134 81 else zprint2("\n");
2135
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 17 times.
98 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2136
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 17 times.
98 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2137
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 17 times.
98 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2138
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 17 times.
98 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2139
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 96 times.
98 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2140
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 17 times.
98 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2141 98 zprint2("\n");
2142 98 }
2143
2144 135 int32_t readheader(PACKFILE *f, zquestheader *Header, bool keepdata, byte printmetadata)
2145 {
2146 int32_t dummy;
2147 zquestheader tempheader;
2148 char dummybuf[80];
2149 byte temp_map_count;
2150 byte temp_midi_flags[MIDIFLAGS_SIZE];
2151 word version;
2152 char temp_pwd[30], temp_pwd2[30];
2153 int16_t temp_pwdkey;
2154 cvs_MD5Context ctx;
2155 135 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2156 135 memset(&tempheader, 0, sizeof(tempheader));
2157 135 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2158
2159
2160
2161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f,true)) // first read old header
2162 {
2163 Z_message("Unable to read header string\n");
2164 return qe_invalid;
2165 }
2166
2167 // check header
2168
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 2 times.
135 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2169 {
2170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(strcmp(tempheader.id_str,QH_IDSTR))
2171 {
2172 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2173 return qe_invalid;
2174 }
2175 2 }
2176
2177 135 int32_t templatepath_len=0;
2178
2179 135 tempheader.external_zinfo = false;
2180 135 read_zinfo = false;
2181
2/2
✓ Branch 0 taken 133 times.
✓ Branch 1 taken 2 times.
135 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2182 {
2183 byte padding;
2184
2185
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&padding,f,true))
2186 {
2187 return qe_invalid;
2188 }
2189
2190
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&tempheader.zelda_version,f,true))
2191 {
2192 return qe_invalid;
2193 }
2194
2195 2 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2196
2197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(tempheader.zelda_version > ZELDA_VERSION)
2198 {
2199 return qe_version;
2200 }
2201
2202 2 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2203
2204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(strcmp(tempheader.id_str,QH_IDSTR))
2205 {
2206 return qe_invalid;
2207 }
2208
2209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(bad_version(tempheader.zelda_version))
2210 {
2211 return qe_obsolete;
2212 }
2213
2214
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&tempheader.internal,f,true))
2215 {
2216 return qe_invalid;
2217 }
2218
2219
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.quest_number,f,true))
2220 {
2221 return qe_invalid;
2222 }
2223
2224 2 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2225
2226
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(&quest_rules[0],2,f,true))
2227 {
2228 return qe_invalid;
2229 }
2230
2231
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&temp_map_count,f,true))
2232 {
2233 return qe_invalid;
2234 }
2235
2236 2 FFCore.quest_format[qMapCount] = temp_map_count;
2237
2238
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.old_str_count,f,true))
2239 {
2240 return qe_invalid;
2241 }
2242
2243
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2244 {
2245 return qe_invalid;
2246 }
2247
2248
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(temp_midi_flags,4,f,true))
2249 {
2250 return qe_invalid;
2251 }
2252
2253
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2254 {
2255 return qe_invalid;
2256 }
2257
2258
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(dummybuf,14,f,true))
2259 {
2260 return qe_invalid;
2261 }
2262
2263
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(&quest_rules[2],2,f,true))
2264 {
2265 return qe_invalid;
2266 }
2267
2268
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&dummybuf,f,true))
2269 {
2270 return qe_invalid;
2271 }
2272
2273
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(tempheader.version,9,f,true))
2274 {
2275 return qe_invalid;
2276 }
2277
2278
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2279 {
2280 return qe_invalid;
2281 }
2282 // These fields are expected to end in null bytes!
2283 2 tempheader.title[sizeof(tempheader.title)-1] = 0;
2284
2285
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2286 {
2287 return qe_invalid;
2288 }
2289 2 tempheader.author[sizeof(tempheader.author)-1] = 0;
2290
2291
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&padding,f,true))
2292 {
2293 return qe_invalid;
2294 }
2295
2296
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_igetw(&temp_pwdkey,f,true))
2297 {
2298 return qe_invalid;
2299 }
2300
2301
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(temp_pwd,30,f,true))
2302 {
2303 return qe_invalid;
2304 }
2305
2306 2 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2307 2 cvs_MD5Init(&ctx);
2308 2 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2309 2 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2310
2311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2312 {
2313 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2314 // Not anymore...
2315 memset(tempheader.minver,0,17);
2316 tempheader.build=0;
2317 tempheader.use_keyfile=0;
2318 memset(tempheader.old_foo, 0, 9);
2319 }
2320 else
2321 {
2322
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(tempheader.minver,9,f,true))
2323 {
2324 return qe_invalid;
2325 }
2326
2327
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.build,f,true))
2328 {
2329 return qe_invalid;
2330 }
2331
2332 2 FFCore.quest_format[vBuild] = tempheader.build;
2333
2334
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!p_getc(&tempheader.use_keyfile,f,true))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(dummybuf,9,f,true))
2340 {
2341 return qe_invalid;
2342 }
2343 } // starting at minver
2344
2345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2346 {
2347 memset(&quest_rules[4],0,16); // word rules3..rules10
2348 }
2349 else
2350 {
2351
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(!pfread(&quest_rules[4],16,f,true)) // read new header additions
2352 {
2353 return qe_invalid; // starting at rules3
2354 }
2355
2356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(tempheader.zelda_version <= 0x190)
2357 {
2358 2 set_bit(quest_rules,qr_MEANPLACEDTRAPS,0);
2359 2 }
2360 }
2361
2362
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((tempheader.zelda_version < 0x192)||
2363 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2364 {
2365 2 set_bit(quest_rules,qr_BRKNSHLDTILES,(get_bit(quest_rules,qr_BRKBLSHLDS_DEP)));
2366 2 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2367 2 }
2368
2369
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2370 {
2371 byte *mf=temp_midi_flags;
2372
2373 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2374 {
2375 mf=(byte*)dummybuf;
2376 }
2377
2378 if(!pfread(mf,32,f,true)) // read new header additions
2379 {
2380 return qe_invalid; // starting at foo2
2381 }
2382
2383 if(!pfread(dummybuf,18,f,true)) // read new header additions
2384 {
2385 return qe_invalid; // starting at foo2
2386 }
2387 }
2388
2389
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((tempheader.zelda_version < 0x192)||
2390 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2391 {
2392 2 memset(tempheader.templatepath,0,2048);
2393 2 }
2394 else
2395 {
2396 if(!pfread(tempheader.templatepath,280,f,true)) // read templatepath
2397 {
2398 return qe_invalid;
2399 }
2400 }
2401
2402
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((tempheader.zelda_version < 0x192)||
2403 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2404 {
2405 2 tempheader.use_keyfile=0;
2406 2 }
2407 2 }
2408 else
2409 {
2410 //section id
2411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(!p_mgetl(&dummy,f,true))
2412 {
2413 return qe_invalid;
2414 }
2415
2416 //section version info
2417
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&version,f,true))
2418 {
2419 return qe_invalid;
2420 }
2421
2422 133 FFCore.quest_format[vHeader] = version;
2423
2424
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&dummy,f,true))
2425 {
2426 return qe_invalid;
2427 }
2428
2429 //section size
2430
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetl(&dummy,f,true))
2431 {
2432 return qe_invalid;
2433 }
2434
2435 //finally... section data
2436
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&tempheader.zelda_version,f,true))
2437 {
2438 return qe_invalid;
2439 }
2440
2441 133 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2442
2443 //do some quick checking...
2444
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(tempheader.zelda_version > ZELDA_VERSION)
2445 {
2446 return qe_version;
2447 }
2448
2449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2450 {
2451 return qe_invalid;
2452 }
2453
2454
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133 times.
133 if(bad_version(tempheader.zelda_version))
2455 {
2456 return qe_obsolete;
2457 }
2458
2459
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&tempheader.build,f,true))
2460 {
2461 return qe_invalid;
2462 }
2463
2464 133 FFCore.quest_format[vBuild] = tempheader.build;
2465
2466
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 128 times.
133 if(version<3)
2467 {
2468
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!pfread(temp_pwd,30,f,true))
2469 {
2470 return qe_invalid;
2471 }
2472
2473
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&temp_pwdkey,f,true))
2474 {
2475 return qe_invalid;
2476 }
2477
2478 5 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2479 5 cvs_MD5Init(&ctx);
2480 5 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strlen(temp_pwd2));
2481 5 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2482 5 }
2483 else
2484 {
2485
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f,true))
2486 {
2487 return qe_invalid;
2488 }
2489 }
2490
2491
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_igetw(&tempheader.internal,f,true))
2492 {
2493 return qe_invalid;
2494 }
2495
2496
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&tempheader.quest_number,f,true))
2497 {
2498 return qe_invalid;
2499 }
2500
2501 133 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2502
2503 133 size_t versz = version < 8 ? 9 : 16;
2504
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(tempheader.version,versz,f,true))
2505 {
2506 return qe_invalid;
2507 }
2508
2509 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2510 //needs to be copied as char[9] or stored as a s.str
2511
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(tempheader.minver,versz,f,true))
2512 {
2513 return qe_invalid;
2514 }
2515
2516 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2517
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(tempheader.title,sizeof(tempheader.title),f,true))
2518 {
2519 return qe_invalid;
2520 }
2521 133 tempheader.title[sizeof(tempheader.title)-1] = 0;
2522
2523
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(tempheader.author,sizeof(tempheader.author),f,true))
2524 {
2525 return qe_invalid;
2526 }
2527 133 tempheader.author[sizeof(tempheader.author)-1] = 0;
2528
2529
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&tempheader.use_keyfile,f,true))
2530 {
2531 return qe_invalid;
2532 }
2533
2534 /*
2535 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f,true))
2536 {
2537 return qe_invalid;
2538 }
2539 */
2540
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f,true))
2541 {
2542 return qe_invalid;
2543 }
2544
2545
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(&dummybuf,4,f,true))
2546 {
2547 return qe_invalid;
2548 }
2549
2550
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f,true))
2551 {
2552 return qe_invalid;
2553 }
2554
2555
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(dummybuf,14,f,true))
2556 {
2557 return qe_invalid;
2558 }
2559
2560 133 templatepath_len=sizeof(tempheader.templatepath);
2561
2562
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 5 times.
133 if(version==1)
2563 {
2564 5 templatepath_len=280;
2565 5 }
2566
2567
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!pfread(tempheader.templatepath,templatepath_len,f,true))
2568 {
2569 return qe_invalid;
2570 }
2571
2572
1/2
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
133 if(!p_getc(&temp_map_count,f,true))
2573 {
2574 return qe_invalid;
2575 }
2576
2577
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 79 times.
133 if(version>=4)
2578 {
2579
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_main,f,true))
2580 {
2581 return qe_invalid;
2582 }
2583
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_second,f,true))
2584 {
2585 return qe_invalid;
2586 }
2587
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_third,f,true))
2588 {
2589 return qe_invalid;
2590 }
2591
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_fourth,f,true))
2592 {
2593 return qe_invalid;
2594 }
2595
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_alpha,f,true))
2596 {
2597 return qe_invalid;
2598 }
2599
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_beta,f,true))
2600 {
2601 return qe_invalid;
2602 }
2603
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_gamma,f,true))
2604 {
2605 return qe_invalid;
2606 }
2607
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.new_version_id_release,f,true))
2608 {
2609 return qe_invalid;
2610 }
2611
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetw(&tempheader.new_version_id_date_year,f,true))
2612 {
2613 return qe_invalid;
2614 }
2615
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&tempheader.new_version_id_date_month,f,true))
2616 {
2617 return qe_invalid;
2618 }
2619
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&tempheader.new_version_id_date_day,f,true))
2620 {
2621 return qe_invalid;
2622 }
2623
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&tempheader.new_version_id_date_hour,f,true))
2624 {
2625 return qe_invalid;
2626 }
2627
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&tempheader.new_version_id_date_minute,f,true))
2628 {
2629 return qe_invalid;
2630 }
2631
2632
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.new_version_devsig,256,f,true))
2633 {
2634 return qe_invalid;
2635 }
2636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2637 strcpy(tempheader.new_version_devsig, "EmilyV99");
2638
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.new_version_compilername,256,f,true))
2639 {
2640 return qe_invalid;
2641 }
2642
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.new_version_compilerversion,256,f,true))
2643 {
2644 return qe_invalid;
2645 }
2646
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.product_name,1024,f,true))
2647 {
2648 return qe_invalid;
2649 }
2650
2651
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&tempheader.compilerid,f,true))
2652 {
2653 return qe_invalid;
2654 }
2655
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.compilerversionnumber_first,f,true))
2656 {
2657 return qe_invalid;
2658 }
2659
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.compilerversionnumber_second,f,true))
2660 {
2661 return qe_invalid;
2662 }
2663
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.compilerversionnumber_third,f,true))
2664 {
2665 return qe_invalid;
2666 }
2667
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f,true))
2668 {
2669 return qe_invalid;
2670 }
2671
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_igetw(&tempheader.developerid,f,true))
2672 {
2673 return qe_invalid;
2674 }
2675
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.made_in_module_name,1024,f,true))
2676 {
2677 return qe_invalid;
2678 }
2679
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.build_datestamp,256,f,true))
2680 {
2681 return qe_invalid;
2682 }
2683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54 times.
54 if(!pfread(tempheader.build_timestamp,256,f,true))
2684 {
2685 return qe_invalid;
2686 }
2687 54 }
2688 else // <4
2689 {
2690 79 tempheader.new_version_id_main = 0;
2691 79 tempheader.new_version_id_second = 0;
2692 79 tempheader.new_version_id_third = 0;
2693 79 tempheader.new_version_id_fourth = 0;
2694 79 tempheader.new_version_id_alpha = 0;
2695 79 tempheader.new_version_id_beta = 0;
2696 79 tempheader.new_version_id_gamma = 0;
2697 79 tempheader.new_version_id_release = 0;
2698 79 tempheader.new_version_id_date_year = 0;
2699 79 tempheader.new_version_id_date_month = 0;
2700 79 tempheader.new_version_id_date_day = 0;
2701 79 tempheader.new_version_id_date_hour = 0;
2702 79 tempheader.new_version_id_date_minute = 0;
2703
2704 79 memset(tempheader.new_version_devsig, 0, 256);
2705 79 memset(tempheader.new_version_compilername, 0, 256);
2706 79 memset(tempheader.new_version_compilerversion, 0, 256);
2707 79 memset(tempheader.product_name, 0, 1024);
2708 79 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2709
2710 79 tempheader.compilerid = 0;
2711 79 tempheader.compilerversionnumber_first = 0;
2712 79 tempheader.compilerversionnumber_second = 0;
2713 79 tempheader.compilerversionnumber_third = 0;
2714 79 tempheader.compilerversionnumber_fourth = 0;
2715 79 tempheader.developerid = 0;
2716
2717 79 memset(tempheader.made_in_module_name, 0, 1024);
2718 79 memset(tempheader.build_datestamp, 0, 256);
2719 79 memset(tempheader.build_timestamp, 0, 256);
2720 }
2721
2722
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 79 times.
133 if ( version >= 5 )
2723 {
2724
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!pfread(tempheader.build_timezone,6,f,true))
2725 {
2726 return qe_invalid;
2727 }
2728 54 }
2729 else // < 5
2730 {
2731 79 memset(tempheader.build_timezone, 0, 6);
2732 }
2733
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 54 times.
133 if ( version >= 6 )
2734 {
2735 byte b;
2736
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&b,f,true))
2737 {
2738 return qe_invalid;
2739 }
2740 54 tempheader.external_zinfo = b?true:false;
2741 54 read_zinfo = true;
2742 54 }
2743
2744
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 79 times.
133 if(version >= 7)
2745 {
2746
1/2
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
54 if(!p_getc(&(tempheader.new_version_is_nightly),f,true))
2747 {
2748 return qe_invalid;
2749 }
2750 54 }
2751 else
2752 {
2753 79 tempheader.new_version_is_nightly = false;
2754
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(tempheader.zelda_version < 0x255)
2755 {
2756
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
79 switch(tempheader.zelda_version)
2757 {
2758 case 0x254:
2759 tempheader.new_version_id_main = 2;
2760 tempheader.new_version_id_second = 54;
2761 break;
2762 case 0x250:
2763
5/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
74 switch(tempheader.build)
2764 {
2765 case 19:
2766 tempheader.new_version_id_main = 2;
2767 tempheader.new_version_id_second = 50;
2768 tempheader.new_version_id_gamma = 1;
2769 break;
2770 case 20:
2771 tempheader.new_version_id_main = 2;
2772 tempheader.new_version_id_second = 50;
2773 tempheader.new_version_id_gamma = 2;
2774 break;
2775 case 21:
2776 tempheader.new_version_id_main = 2;
2777 tempheader.new_version_id_second = 50;
2778 tempheader.new_version_id_gamma = 3;
2779 break;
2780 case 22:
2781 tempheader.new_version_id_main = 2;
2782 tempheader.new_version_id_second = 50;
2783 tempheader.new_version_id_gamma = 4;
2784 break;
2785 case 23:
2786 tempheader.new_version_id_main = 2;
2787 tempheader.new_version_id_second = 50;
2788 tempheader.new_version_id_gamma = 5;
2789 break;
2790 case 24:
2791 22 tempheader.new_version_id_main = 2;
2792 22 tempheader.new_version_id_second = 50;
2793 22 tempheader.new_version_id_release = -1;
2794 22 break;
2795 case 25:
2796 tempheader.new_version_id_main = 2;
2797 tempheader.new_version_id_second = 50;
2798 tempheader.new_version_id_third = 1;
2799 tempheader.new_version_id_gamma = 1;
2800 break;
2801 case 26:
2802 tempheader.new_version_id_main = 2;
2803 tempheader.new_version_id_second = 50;
2804 tempheader.new_version_id_third = 1;
2805 tempheader.new_version_id_gamma = 2;
2806 break;
2807 case 27:
2808 tempheader.new_version_id_main = 2;
2809 tempheader.new_version_id_second = 50;
2810 tempheader.new_version_id_third = 1;
2811 tempheader.new_version_id_gamma = 3;
2812 break;
2813 case 28:
2814 5 tempheader.new_version_id_main = 2;
2815 5 tempheader.new_version_id_second = 50;
2816 5 tempheader.new_version_id_third = 1;
2817 5 tempheader.new_version_id_release = -1;
2818 5 break;
2819 case 29:
2820 24 tempheader.new_version_id_main = 2;
2821 24 tempheader.new_version_id_second = 50;
2822 24 tempheader.new_version_id_third = 2;
2823 24 tempheader.new_version_id_release = -1;
2824 24 break;
2825 case 30:
2826 tempheader.new_version_id_main = 2;
2827 tempheader.new_version_id_second = 50;
2828 tempheader.new_version_id_third = 3;
2829 tempheader.new_version_id_gamma = 1;
2830 break;
2831 case 31:
2832 15 tempheader.new_version_id_main = 2;
2833 15 tempheader.new_version_id_second = 53;
2834 15 tempheader.new_version_id_gamma = -1;
2835 15 break;
2836 case 32:
2837 8 tempheader.new_version_id_main = 2;
2838 8 tempheader.new_version_id_second = 53;
2839 8 tempheader.new_version_id_release = -1;
2840 8 break;
2841 case 33:
2842 tempheader.new_version_id_main = 2;
2843 tempheader.new_version_id_second = 53;
2844 tempheader.new_version_id_third = 1;
2845 break;
2846 }
2847 74 break;
2848
2849 case 0x211:
2850 tempheader.new_version_id_main = 2;
2851 tempheader.new_version_id_second = 11;
2852 tempheader.new_version_id_beta = tempheader.build;
2853 break;
2854 case 0x210:
2855 5 tempheader.new_version_id_main = 2;
2856 5 tempheader.new_version_id_second = 10;
2857 5 tempheader.new_version_id_beta = tempheader.build;
2858 5 break;
2859 }
2860 79 }
2861 }
2862
2/4
✓ Branch 0 taken 133 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133 times.
133 if(printmetadata || __isZQuest)
2863 {
2864 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2865 }
2866 }
2867
2868 //{ Version Warning
2869 135 int32_t vercmp = tempheader.compareVer();
2870 135 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
2871 135 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
2872
4/6
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 54 times.
189 if(vercmp > 0 || (!vercmp &&
2873
2/4
✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
54 (astatecmp > 0 || (!astatecmp &&
2874 54 avercmp > 0))))
2875 {
2876 bool r = true;
2877 if(loadquest_report)
2878 {
2879 enter_sys_pal();
2880 AlertDialog("Quest saved in newer version",
2881 "This quest was last saved in a newer version of ZQuest."
2882 " Attempting to load this quest may not work correctly; to"
2883 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2884 "\n\nWould you like to continue loading anyway? (Not recommended)",
2885 [&](bool ret,bool)
2886 {
2887 r = ret;
2888 }).show();
2889 exit_sys_pal();
2890 }
2891 if(!r)
2892 return qe_silenterr;
2893 }
2894
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 else if(tempheader.compareDate() > 0)
2895 {
2896 bool r = true;
2897 if(loadquest_report)
2898 {
2899 enter_sys_pal();
2900 AlertDialog("Quest saved in newer build",
2901 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2902 " issues loading in this build."
2903 "\n{}"
2904 "\n\nWould you like to continue loading anyway?",
2905 tempheader.getVerCmpStr()),
2906 [&](bool ret,bool)
2907 {
2908 r = ret;
2909 }).show();
2910 exit_sys_pal();
2911 }
2912 if(!r)
2913 return qe_silenterr;
2914 }
2915 //}
2916
2917 135 read_ext_zinfo = tempheader.external_zinfo;
2918
2919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 135 times.
135 if(keepdata==true)
2920 {
2921 135 memcpy(Header, &tempheader, sizeof(tempheader));
2922 135 map_count=temp_map_count;
2923 135 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2924 135 }
2925
2926 135 return 0;
2927 135 }
2928
2929 104 int32_t readrules(PACKFILE *f, zquestheader *Header, bool keepdata)
2930 {
2931 int32_t dummy;
2932 zquestheader tempheader;
2933 104 word s_version=0;
2934 104 dword compatrule_version=0;
2935
2936 104 memcpy(&tempheader, Header, sizeof(tempheader));
2937
2938
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(tempheader.zelda_version >= 0x193)
2939 {
2940 //section version info
2941
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
2942 {
2943 return qe_invalid;
2944 }
2945
2946 102 FFCore.quest_format[vRules] = s_version;
2947
2948
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy,f,true))
2949 {
2950 return qe_invalid;
2951 }
2952
2953
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if(s_version > 16)
2954 {
2955
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&compatrule_version,f,true))
2956 {
2957 return qe_invalid;
2958 }
2959 23 }
2960 102 FFCore.quest_format[vCompatRule] = compatrule_version;
2961
2962 //section size
2963
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
2964 {
2965 return qe_invalid;
2966 }
2967
2968
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if ( s_version < 15 )
2969 {
2970 //finally... section data
2971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(!pfread(quest_rules,QUESTRULES_SIZE,f,true))
2972 {
2973 return qe_invalid;
2974 }
2975 79 }
2976 else
2977 {
2978
2979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f,true))
2980 {
2981 return qe_invalid;
2982 }
2983
2984 }
2985 102 }
2986
2987 //al_trace("Rules version %d\n", s_version);
2988 //{ bunch of compat stuff
2989 104 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2990
2991
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<2)
2992 {
2993 7 set_bit(quest_rules,14,0);
2994 7 set_bit(quest_rules,27,0);
2995 7 set_bit(quest_rules,28,0);
2996 7 set_bit(quest_rules,29,0);
2997 7 set_bit(quest_rules,30,0);
2998 7 set_bit(quest_rules,32,0);
2999 7 set_bit(quest_rules,36,0);
3000 7 set_bit(quest_rules,49,0);
3001 7 set_bit(quest_rules,50,0);
3002 7 set_bit(quest_rules,51,0);
3003 7 set_bit(quest_rules,68,0);
3004 7 set_bit(quest_rules,75,0);
3005 7 set_bit(quest_rules,76,0);
3006 7 set_bit(quest_rules,98,0);
3007 7 set_bit(quest_rules,110,0);
3008 7 set_bit(quest_rules,113,0);
3009 7 set_bit(quest_rules,116,0);
3010 7 set_bit(quest_rules,102,0);
3011 7 set_bit(quest_rules,132,0);
3012 7 }
3013
3014 //Now, do any updates...
3015
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3016 {
3017 7 set_bit(quest_rules, qr_SMOOTHVERTICALSCROLLING,1);
3018 7 set_bit(quest_rules, qr_REPLACEOPENDOORS, 1);
3019 7 set_bit(quest_rules, qr_OLDLENSORDER, 1);
3020 7 set_bit(quest_rules, qr_NOFAIRYGUYFIRES, 1);
3021 7 set_bit(quest_rules, qr_TRIGGERSREPEAT, 1);
3022 7 }
3023
3024
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3025 {
3026 2 set_bit(quest_rules,qr_WALLFLIERS,1);
3027 2 }
3028
3029
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3030 {
3031 2 set_bit(quest_rules,qr_NOBOMBPALFLASH,1);
3032 2 }
3033
3034
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3035 {
3036 2 set_bit(quest_rules,qr_NOSCROLLCONTINUE,1);
3037 2 }
3038
3039
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(tempheader.zelda_version <= 0x210)
3040 {
3041 7 set_bit(quest_rules,qr_ARROWCLIP,1);
3042 7 }
3043
3044
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(tempheader.zelda_version == 0x210)
3045 {
3046 5 set_bit(quest_rules, qr_NOSCROLLCONTINUE, get_bit(quest_rules, qr_CMBCYCLELAYERS));
3047 5 set_bit(quest_rules, qr_CMBCYCLELAYERS, 0);
3048 5 set_bit(quest_rules, qr_CONT_SWORD_TRIGGERS, 1);
3049 5 }
3050
3051
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(tempheader.zelda_version <= 0x210)
3052 {
3053 7 set_bit(quest_rules,qr_OLDSTYLEWARP,1);
3054 7 set_bit(quest_rules,qr_210_WARPRETURN,1);
3055 7 }
3056
3057 //might not be correct
3058
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(tempheader.zelda_version < 0x210)
3059 {
3060 2 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3061 2 set_bit(quest_rules, qr_OLDHOOKSHOTGRAB,1);
3062 2 }
3063
3064
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(tempheader.zelda_version < 0x211)
3065 {
3066 7 set_bit(quest_rules, qr_WRONG_BRANG_TRAIL_DIR,1);
3067 7 }
3068
3069
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3070 {
3071 set_bit(quest_rules, qr_192b163_WARP,1);
3072 }
3073
3074
2/2
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 5 times.
104 if(tempheader.zelda_version == 0x210)
3075 {
3076 5 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_bit(quest_rules, qr_DMGCOMBOPRI));
3077 5 set_bit(quest_rules, qr_DMGCOMBOPRI, 0);
3078 5 }
3079
3080
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3081 {
3082 7 set_bit(quest_rules, qr_OLDPICKUP,1);
3083 7 }
3084
3085
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3086 {
3087 7 set_bit(quest_rules,qr_NOSOLIDDAMAGECOMBOS, 1);
3088 7 set_bit(quest_rules, qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3089 7 }
3090
3091
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3092 {
3093 7 set_bit(quest_rules,qr_HOOKSHOTDOWNBUG, 1);
3094 7 }
3095
3096
4/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 22 times.
104 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3097 {
3098 22 set_bit(quest_rules,qr_PEAHATCLOCKVULN, 1);
3099 22 }
3100
3101
5/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3102 {
3103 7 set_bit(quest_rules,qr_OLD_DOORREPAIR, 1);
3104 7 }
3105
3106
5/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 74 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3107 {
3108 7 set_bit(quest_rules,qr_OLD_SECRETMONEY, 1);
3109 7 }
3110
3111
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3112 {
3113 29 set_bit(quest_rules,qr_OLD_POTION_OR_HC, 1);
3114 29 }
3115
3116
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3117 {
3118 29 set_bit(quest_rules, qr_OFFSCREENWEAPONS, 1);
3119 29 }
3120
3121 //Bombchu fix.
3122
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 74 times.
104 if(tempheader.zelda_version == 0x250)
3123 {
3124
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 22 times.
74 if ( tempheader.build == 24 ) //2.50.0
3125 {
3126 22 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3127 22 }
3128
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 5 times.
74 if ( tempheader.build == 28 ) //2.50.1
3129 {
3130 5 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 1);
3131 5 }
3132
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
74 if ( tempheader.build == 29 ) //2.50.2
3133 {
3134 24 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3135 24 }
3136
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if ( tempheader.build == 30 ) //2.50.3RC1
3137 {
3138 set_bit(quest_rules, qr_BOMBCHUSUPERBOMB, 0);
3139 }
3140 74 }
3141
3142
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3143 {
3144 // qr_OFFSETEWPNCOLLISIONFIX
3145 // All 'official' quests need this disabled.
3146 // All 2.10 and lower quests need this enabled to preseve compatability.
3147 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3148
3149 //~Gleeok
3150 34 set_bit(quest_rules, qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3151
3152 // Broke in build 695
3153
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
34 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3154 27 set_bit(quest_rules, qr_BROKENSTATUES, 1);
3155 34 }
3156
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if (tempheader.zelda_version <= 0x190)
3157 {
3158 2 set_bit(quest_rules, qr_COPIED_SWIM_SPRITES, 1);
3159 2 }
3160
7/10
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 30 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 9 taken 23 times.
104 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3161 {
3162 81 set_bit(quest_rules, qr_OLD_SLASHNEXT_SECRETS, 1);
3163 81 }
3164
3165
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3166 {
3167 7 set_bit(quest_rules, qr_OLD_210_WATER, 1);
3168 7 }
3169
3170
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3171 {
3172 81 set_bit(quest_rules,qr_STEP_IS_FLOAT,0);
3173 81 }
3174
3175
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if ( tempheader.zelda_version < 0x250 )
3176 {
3177 7 set_bit(quest_rules, qr_8WAY_SHOT_SFX, 1);
3178 7 }
3179
3180
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version < 3)
3181 {
3182 7 set_bit(quest_rules, qr_HOLDNOSTOPMUSIC, 1);
3183 7 set_bit(quest_rules, qr_CAVEEXITNOSTOPMUSIC, 1);
3184 7 }
3185
3186
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<4)
3187 {
3188 7 set_bit(quest_rules,10,0);
3189 7 }
3190
3191
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<5)
3192 {
3193 7 set_bit(quest_rules,27,0);
3194 7 }
3195
3196
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<6)
3197 {
3198 7 set_bit(quest_rules,46,0);
3199 7 }
3200
3201
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<7) // January 2008
3202 {
3203 7 set_bit(quest_rules,qr_HEARTSREQUIREDFIX,0);
3204 7 set_bit(quest_rules,qr_PUSHBLOCKCSETFIX,1);
3205 7 }
3206
3207
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(s_version<8)
3208 {
3209 7 set_bit(quest_rules, 12, 0);
3210 7 }
3211 else
3212 {
3213 97 set_bit(deprecated_rules, 12, 0);
3214 }
3215
3216
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<9) // October 2008
3217 {
3218 7 set_bit(quest_rules,qr_NOROPE2FLASH_DEP,0);
3219 7 set_bit(quest_rules,qr_NOBUBBLEFLASH_DEP,0);
3220 7 set_bit(quest_rules,qr_GHINI2BLINK_DEP,0);
3221 7 set_bit(quest_rules,qr_PHANTOMGHINI2_DEP,0);
3222 7 }
3223
3224
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<10) // December 2008
3225 {
3226 7 set_bit(quest_rules,qr_NOCLOCKS_DEP,0);
3227 7 set_bit(quest_rules, qr_ALLOW10RUPEEDROPS_DEP,0);
3228 7 }
3229
3230
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<11) // April 2009
3231 {
3232 7 set_bit(quest_rules,qr_SLOWENEMYANIM_DEP,0);
3233 7 }
3234
3235
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<12) // December 2009
3236 {
3237 7 set_bit(quest_rules,qr_BRKBLSHLDS_DEP,0);
3238 7 set_bit(quest_rules, qr_OLDTRIBBLES_DEP,0);
3239 7 }
3240
3241 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3242
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version < 13)
3243 {
3244 7 set_bit(quest_rules,qr_SHOPCHEAT, 1);
3245 7 }
3246
3247 // Not entirely sure this is the best place for this...
3248 //2.50.2 bitmap offset fix
3249 104 memset(extra_rules, 0, EXTRARULES_SIZE);
3250
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 47 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3251 {
3252 34 set_bit(extra_rules, er_BITMAPOFFSET, 1);
3253 34 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 1);
3254 34 }
3255 //required because quest templates also used this bit, although
3256 //it never did anything, before. -Z
3257
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 74 times.
104 if ( tempheader.zelda_version == 0x250 )
3258 {
3259
5/6
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 50 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 35 times.
74 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3260 {
3261 39 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3262 39 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3263 39 }
3264 74 }
3265
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if ( tempheader.zelda_version == 0x254 )
3266 {
3267 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3268 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3269 }
3270
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
104 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3271 {
3272 set_bit(extra_rules, er_BITMAPOFFSET, 0);
3273 set_bit(quest_rules, qr_BITMAPOFFSETFIX, 0);
3274 }
3275 //optimise fast drawing for older versions.
3276
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3277 {
3278 81 set_bit(quest_rules, qr_OLDSPRITEDRAWS, 1);
3279 81 }
3280 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3281 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3282 //older quests can set the rule by hand. We need a new qst.dat again.
3283
4/6
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3284 {
3285 set_bit(quest_rules, qr_OLDEWPNPARENT, 1);
3286 }
3287
4/6
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3288 {
3289 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 1);
3290 }
3291
4/6
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3292 {
3293 set_bit(quest_rules, qr_OLDQUESTMISC, 1);
3294 }
3295
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( tempheader.zelda_version < 0x254 )
3296 {
3297 81 set_bit(quest_rules, qr_OLDCREATEBITMAP_ARGS, 0);
3298 81 set_bit(quest_rules, qr_OLDEWPNPARENT, 0);
3299 81 set_bit(quest_rules, qr_OLDQUESTMISC, 0);
3300 81 }
3301
3302 //item scripts continue to run
3303
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3304 {
3305 81 set_bit(quest_rules, qr_ITEMSCRIPTSKEEPRUNNING, 0);
3306 81 set_bit(quest_rules, qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3307 81 set_bit(quest_rules, qr_FIXSCRIPTSDURINGSCROLLING, 0);
3308 81 set_bit(quest_rules, qr_SCRIPTDRAWSINWARPS, 0);
3309 81 set_bit(quest_rules, qr_DYINGENEMYESDONTHURTHERO, 0);
3310 81 set_bit(quest_rules, qr_OUTOFBOUNDSENEMIES, 0);
3311 81 set_bit(quest_rules, qr_SPRITEXY_IS_FLOAT, 0);
3312 81 }
3313
3314
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3315 {
3316 81 set_bit(quest_rules, qr_CLEARINITDONSCRIPTCHANGE, 1);
3317 81 }
3318
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3319 {
3320 81 set_bit(quest_rules, qr_TRACESCRIPTIDS, 0);
3321 81 set_bit(quest_rules, qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3322 81 set_bit(quest_rules, qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3323 81 set_bit(quest_rules,qr_PARSER_250DIVISION,1);
3324 81 set_bit(quest_rules,qr_PARSER_BOOL_TRUE_DECIMAL,1);
3325 81 set_bit(quest_rules,qr_PARSER_TRUE_INT_SIZE,0);
3326 81 set_bit(quest_rules,qr_PARSER_FORCE_INLINE,0);
3327 81 set_bit(quest_rules,qr_PARSER_BINARY_32BIT,0);
3328
2/2
✓ Branch 0 taken 80 times.
✓ Branch 1 taken 1 times.
81 if ( get_bit(quest_rules, qr_SELECTAWPN) )
3329 {
3330 1 set_bit(quest_rules,qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3331 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3332 //Now they **do**, unless you disable that behaviour.
3333 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3334 //now enable the disable L/R item swap on load.
3335 1 }
3336
3337 81 }
3338
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3339 {
3340 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3341 81 set_bit(quest_rules, qr_DISALLOW_SETTING_RAFTING, 1);
3342 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3343 //animations ending earlier than they should.
3344 81 set_bit(quest_rules, qr_BROKEN_ASKIP_Y_FRAMES, 1);
3345 //Enemies would ignore solidity on the top half of combos
3346 81 set_bit(quest_rules, qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3347 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3348 81 set_bit(quest_rules, qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3349 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3350 81 set_bit(quest_rules, qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3351 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3352 81 set_bit(quest_rules, qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3353 81 }
3354
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( tempheader.zelda_version < 0x255 )
3355 {
3356 81 set_bit(quest_rules, qr_NOFFCWAITDRAW, 1);
3357 81 set_bit(quest_rules, qr_NOITEMWAITDRAW, 1);
3358 81 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3359 81 set_bit(quest_rules, qr_OLD_INIT_SCRIPT_TIMING, 1);
3360 //set_bit(quest_rules, qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3361 81 }
3362
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3363 {
3364 81 set_bit(quest_rules, qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3365 81 }
3366
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3367 {
3368 81 set_bit(quest_rules, qr_OLD_PRINTF_ARGS, 1);
3369 81 }
3370
3371
3372
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3373 {
3374 81 set_bit(quest_rules, qr_BROKEN_RING_POWER, 1);
3375 81 }
3376
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3377 {
3378 81 set_bit(quest_rules, qr_NO_OVERWORLD_MAP_CHARTING, 1);
3379 81 }
3380
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3381 {
3382 81 set_bit(quest_rules, qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3383 81 }
3384
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3385 {
3386 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3387
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(get_bit(quest_rules,qr_SET_XBUTTON_ITEMS))
3388 set_bit(quest_rules,qr_SET_YBUTTON_ITEMS,1);
3389 81 }
3390
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3391 {
3392 81 set_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0,1);
3393 81 }
3394
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3395 {
3396 81 set_bit(quest_rules,qr_OLD_CHEST_COLLISION,1);
3397 81 }
3398
3399
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( tempheader.zelda_version < 0x254 )
3400 {
3401 81 set_bit(quest_rules, qr_250WRITEEDEFSCRIPT, 1);
3402 81 }
3403 //Sideview spikes in 2.50.0
3404
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 52 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3405 {
3406 29 set_bit(quest_rules, qr_OLDSIDEVIEWSPIKES, 1);
3407 29 }
3408 //more 2.50 fixes -Z
3409
6/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 23 times.
104 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3410 {
3411 58 set_bit(quest_rules, qr_MELEEMAGICCOST, 0);
3412 58 set_bit(quest_rules, qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3413 58 set_bit(quest_rules, qr_OLDMIRRORCOMBOS, 1);
3414 58 set_bit(quest_rules, qr_BROKENBOOKCOST, 1);
3415 58 set_bit(quest_rules, qr_BROKENCHARINTDRAWING, 1);
3416
3417 58 }
3418
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3419 {
3420 //set_bit(quest_rules,qr_MELEEMAGICCOST, get_bit(extra_rules,er_MAGICCOSTSWORD));
3421 set_bit(quest_rules,qr_MELEEMAGICCOST, 1);
3422 }
3423
3424
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(tempheader.zelda_version < 0x193)
3425 {
3426 2 set_bit(quest_rules, qr_SHORTDGNWALK, 1);
3427 2 }
3428
3429
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(tempheader.zelda_version < 0x255)
3430 {
3431 81 set_bit(quest_rules, qr_OLDINFMAGIC, 1);
3432 81 }
3433
3434
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3435 {
3436 7 set_bit(quest_rules,qr_SIDEVIEWTRIFORCECELLAR,1);
3437 7 }
3438
3439
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3440 {
3441 81 set_bit(quest_rules,qr_OLD_F6,1);
3442 81 }
3443
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3444 {
3445 81 set_bit(quest_rules,qr_NO_OVERWRITING_HOPPING,1);
3446 81 }
3447
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3448 {
3449 81 set_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3450 81 }
3451
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3452 {
3453 81 set_bit(quest_rules,qr_BROKEN_OVERWORLD_MINIMAP,1);
3454 81 }
3455 //}
3456
3457
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3458 81 set_bit(quest_rules,qr_ENEMIES_SECRET_ONLY_16_31,1);
3459
3460
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 2) //Old CSet2 Handling
3461 81 set_bit(quest_rules,qr_OLDCS2,1);
3462
3463
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3464 81 set_bit(quest_rules,qr_HARDCODED_ENEMY_ANIMS,1);
3465
3466
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3467 81 set_bit(quest_rules,qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3468
3469
4/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 74 times.
104 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3470 74 set_bit(quest_rules,qr_NO_LANMOLA_RINGLEADER,1);
3471
3472
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3473 81 set_bit(quest_rules,qr_STEPTEMP_SECRET_ONLY_16_31,1);
3474
3475
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3476 81 set_bit(quest_rules,qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3477
3478
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3479 81 set_bit(quest_rules,qr_HARDCODED_LITEM_LTMS,1);
3480
3481
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 9)
3482 {
3483 //Hardcoded BS Patras
3484 81 set_bit(quest_rules,qr_HARDCODED_BS_PATRA,1);
3485 //Hardcoded Patra Inner Eye offsets
3486 81 set_bit(quest_rules,qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3487 //Broken 'Big enemy' animation style
3488 81 set_bit(quest_rules,qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3489 //Broken Attribute 31/32
3490 81 set_bit(quest_rules,qr_BROKEN_ATTRIBUTE_31_32,1);
3491 81 }
3492
3493
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 10) //Shared candle use limits
3494 81 set_bit(quest_rules,qr_CANDLES_SHARED_LIMIT,1);
3495
3496
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 11) //No cross-screen return points
3497 81 set_bit(quest_rules,qr_OLD_RESPAWN_POINTS,1);
3498
3499
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 12)
3500 {
3501 //Old fire trail duration
3502 81 set_bit(quest_rules,qr_OLD_FLAMETRAIL_DURATION,1);
3503 //Old Intro String in Ganon Room Behavior
3504
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(get_bit(quest_rules,qr_GANONINTRO)) set_bit(quest_rules,qr_GANONINTRO,0);
3505 81 else set_bit(quest_rules,qr_GANONINTRO,1);
3506 81 }
3507
3508
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 81 times.
✗ Branch 3 not taken.
104 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3509 set_bit(quest_rules,qr_ANONE_NOANIM,1);
3510
3511
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 14) //Old Bridge Combo Behavior
3512 81 set_bit(quest_rules,qr_OLD_BRIDGE_COMBOS,1);
3513
3514
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 15) //Broken Z3 Animation
3515 81 set_bit(quest_rules,qr_BROKEN_Z3_ANIMATION,1);
3516
3517
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3518 81 set_bit(quest_rules,qr_OLD_TILE_INITIALIZATION,1);
3519
3520
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 17)
3521 {
3522 //Old Quake/DrawYOffset behavior
3523 //set_bit(quest_rules,qr_OLD_DRAWOFFSET,1);
3524 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3525 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3526 81 }
3527
3528
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 18)
3529 {
3530 //Broken DrawScreen Derivative Functions
3531 81 set_bit(quest_rules,qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3532 //Scrolling Cancels Charge
3533 81 set_bit(quest_rules,qr_SCROLLING_KILLS_CHARGE,1);
3534 81 }
3535
3536
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3537 81 set_bit(quest_rules,qr_BROKEN_ITEM_CARRYING,1);
3538
3539
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 20)
3540 81 set_bit(quest_rules,qr_CUSTOMWEAPON_IGNORE_COST,1);
3541
3542
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 21)
3543 {
3544 81 set_bit(quest_rules,qr_LEEVERS_DONT_OBEY_STUN,1);
3545 81 set_bit(quest_rules,qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3546 81 set_bit(quest_rules,qr_WIZZROBES_DONT_OBEY_STUN,1);
3547 81 set_bit(quest_rules,qr_OLD_BUG_NET,1);
3548 81 set_bit(quest_rules,qr_MANHANDLA_BLOCK_SFX,1);
3549 81 }
3550
3551
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 22)
3552 81 set_bit(quest_rules,qr_BROKEN_KEEPOLD_FLAG,1);
3553
3554
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 23)
3555 81 set_bit(quest_rules,qr_OLD_HALF_MAGIC,1);
3556
3557
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 24)
3558 {
3559 81 set_bit(quest_rules,qr_WARPS_RESTART_DMAPSCRIPT,1);
3560 81 set_bit(quest_rules,qr_DMAP_0_CONTINUE_BUG,1);
3561 81 }
3562
3563
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 25)
3564 {
3565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if (get_bit(quest_rules, qr_OLD_FAIRY_LIMIT)) set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,0);
3566 81 else set_bit(quest_rules,qr_OLD_FAIRY_LIMIT,1);
3567 81 set_bit(quest_rules,qr_OLD_SCRIPTED_KNOCKBACK,1);
3568 81 }
3569
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 26)
3570 {
3571 81 set_bit(quest_rules,qr_OLD_KEESE_Z_AXIS,1);
3572 81 set_bit(quest_rules,qr_POLVIRE_NO_SHADOW,1);
3573 81 set_bit(quest_rules,qr_SUBSCR_OLD_SELECTOR,1);
3574 81 }
3575
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3576 {
3577
2/2
✓ Branch 0 taken 24381 times.
✓ Branch 1 taken 81 times.
24462 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3578 24381 set_bit(quest_rules,q,0);
3579
2/2
✓ Branch 0 taken 9072 times.
✓ Branch 1 taken 81 times.
9153 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3580 9072 set_bit(quest_rules,q,0);
3581 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3582 81 }
3583
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 28)
3584 83 set_bit(quest_rules,qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3585
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 29)
3586 83 set_bit(quest_rules,qr_OLD_LOCKBLOCK_COLLISION,1);
3587
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 30)
3588 {
3589 83 set_bit(quest_rules,qr_DECO_2_YOFFSET,1);
3590 83 set_bit(quest_rules,qr_SCREENSTATE_80s_BUG,1);
3591 83 }
3592
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 31)
3593 {
3594 83 set_bit(quest_rules,qr_GOHMA_UNDAMAGED_BUG,1);
3595 83 set_bit(quest_rules,qr_FFCPRELOAD_BUGGED_LOAD,1);
3596 83 }
3597
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 32)
3598 83 set_bit(quest_rules,qr_BROKEN_GETPIXEL_VALUE,1);
3599
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(compatrule_version < 33)
3600 83 set_bit(quest_rules,qr_NO_LIFT_SPRITE,1);
3601
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 91 times.
104 if(compatrule_version < 34)
3602 {
3603 91 set_bit(quest_rules,qr_OLD_SIDEVIEW_LANDING_CODE,1);
3604 91 set_bit(quest_rules,qr_OLD_FFC_SPEED_CAP,1);
3605 91 set_bit(quest_rules,qr_OLD_FFC_FUNCTIONALITY,1);
3606 91 set_bit(quest_rules,qr_OLD_WIZZROBE_SUBMERGING,1);
3607 91 }
3608
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 93 times.
104 if(compatrule_version < 35)
3609 {
3610 // Leaving this commented for now, might need to enable later -Em
3611 // set_bit(quest_rules,qr_ZS_NO_NEG_ARRAY,1);
3612 93 }
3613
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 93 times.
104 if(compatrule_version < 36)
3614 93 set_bit(quest_rules,qr_OLD_SHALLOW_SFX,1);
3615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(compatrule_version < 37)
3616 104 set_bit(quest_rules,qr_SPARKLES_INHERIT_PROPERTIES,1);
3617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(compatrule_version < 38)
3618 104 set_bit(quest_rules,qr_BUGGED_LAYERED_FLAGS,1);
3619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(compatrule_version < 39)
3620 104 set_bit(quest_rules,qr_HARDCODED_FFC_BUSH_DROPS,1);
3621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(compatrule_version < 40)
3622 104 set_bit(quest_rules,qr_MOVINGBLOCK_FAKE_SOLID,1);
3623
3624 104 set_bit(quest_rules,qr_ANIMATECUSTOMWEAPONS,0);
3625
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if (s_version < 16)
3626 81 set_bit(quest_rules,qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3627
3628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
3629 104 memcpy(Header, &tempheader, sizeof(tempheader));
3630
3631 104 return 0;
3632 104 }
3633
3634 862333 void init_msgstr(MsgStr *str)
3635 {
3636 862333 str->s = "";
3637 862333 str->s.shrink_to_fit();
3638 862333 str->nextstring=0;
3639 862333 str->tile=0;
3640 862333 str->cset=0;
3641 862333 str->trans=false;
3642 862333 str->font=font_zfont;
3643 862333 str->y=32;
3644 862333 str->sfx=18;
3645 862333 str->listpos=0;
3646 862333 str->x=24;
3647 862333 str->w=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3648 862333 str->h=get_bit(quest_rules,qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3649 862333 str->hspace=0;
3650 862333 str->vspace=0;
3651 862333 str->stringflags=0;
3652 862333 str->margins[up] = 8;
3653 862333 str->margins[down] = 0;
3654 862333 str->margins[left] = 8;
3655 862333 str->margins[right] = 0;
3656 862333 str->portrait_tile = 0;
3657 862333 str->portrait_cset = 0;
3658 862333 str->portrait_x = 0;
3659 862333 str->portrait_y = 0;
3660 862333 str->portrait_tw = 1;
3661 862333 str->portrait_th = 1;
3662 862333 str->shadow_type = 0;
3663 862333 str->shadow_color = 0;
3664 862333 str->drawlayer = 6;
3665 862333 }
3666
3667 104 void init_msgstrings(int32_t start, int32_t end)
3668 {
3669
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(end <= start || end-start > msg_strings_size)
3670 return;
3671
3672
2/2
✓ Branch 0 taken 851968 times.
✓ Branch 1 taken 104 times.
852072 for(int32_t i=start; i<end; i++)
3673 {
3674 851968 init_msgstr(&MsgStrings[i]);
3675 851968 MsgStrings[i].listpos=i;
3676 851968 }
3677
3678
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(start==0)
3679 {
3680 104 MsgStrings[0].s = "(None)";
3681 104 MsgStrings[0].listpos = 0;
3682 104 }
3683 104 }
3684
3685 104 int32_t readstrings(PACKFILE *f, zquestheader *Header, bool keepdata)
3686 {
3687 104 MsgStr tempMsgString;
3688
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 init_msgstr(&tempMsgString);
3689
3690 104 word temp_msg_count=0;
3691 word temp_expansion[16];
3692 104 memset(temp_expansion, 0, 16*sizeof(word));
3693 104 char buf[8193] = {0};
3694
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version < 0x193)
3695 {
3696 byte tempbyte;
3697 2 int32_t strings_to_read=0;
3698
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3699
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((Header->zelda_version < 0x192)||
3700 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3701 {
3702 2 strings_to_read=128;
3703 2 temp_msg_count=Header->old_str_count;
3704
3705 // Some sort of string count corruption seems to be common in old quests
3706
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(temp_msg_count>128)
3707 {
3708 temp_msg_count=128;
3709 }
3710 2 }
3711 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3712 {
3713 strings_to_read=255;
3714 temp_msg_count=Header->old_str_count;
3715 }
3716 else
3717 {
3718 if(!p_igetw(&temp_msg_count,f,true))
3719 {
3720 return qe_invalid;
3721 }
3722
3723 strings_to_read=temp_msg_count;
3724
3725 if(temp_msg_count >= msg_strings_size)
3726 {
3727 Z_message("Reallocating string buffer...\n");
3728
3729 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3730 // return qe_nomem;
3731
3732 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3733 delete[] MsgStrings;
3734 MsgStrings = new MsgStr[MAXMSGS];
3735 msg_strings_size = MAXMSGS;
3736 for(auto q = 0; q < msg_strings_size; ++q)
3737 {
3738 MsgStrings[q].clear();
3739 }
3740 }
3741 }
3742
3743 //reset the message strings
3744
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(keepdata)
3745 {
3746
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 init_msgstrings(0,msg_strings_size);
3747 2 }
3748
3749
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 2 times.
258 for(int32_t x=0; x<strings_to_read; x++)
3750 {
3751
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 init_msgstr(&tempMsgString);
3752
3753
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!pfread(buf,73,f,true))
3754 {
3755 return qe_invalid;
3756 }
3757
3758 256 buf[74] = '\0';
3759
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 tempMsgString.s = buf;
3760
3761
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!p_getc(&tempbyte,f,true))
3762 {
3763 return qe_invalid;
3764 }
3765
3766
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
256 if((Header->zelda_version < 0x192)||
3767 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3768 {
3769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
256 tempMsgString.nextstring=tempbyte?x+1:0;
3770
3771
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!p_getc(&tempbyte,f,true))
3772 {
3773 return qe_invalid;
3774 }
3775
3776
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!p_getc(&tempbyte,f,true))
3777 {
3778 return qe_invalid;
3779 }
3780 256 }
3781 else
3782 {
3783 if(!p_igetw(&tempMsgString.nextstring,f,true))
3784 {
3785 return qe_invalid;
3786 }
3787
3788 if(!pfread(temp_expansion,32,f,true))
3789 {
3790 return qe_invalid;
3791 }
3792 }
3793
3794
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(keepdata==true)
3795 {
3796
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 MsgStrings[x] = tempMsgString;
3797 256 }
3798 256 }
3799 2 }
3800 else
3801 {
3802 int32_t dummy_int;
3803 word s_version;
3804 word s_cversion;
3805
3806 //section version info
3807
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&s_version,f,true))
3808 {
3809 return qe_invalid;
3810 }
3811
3812 102 FFCore.quest_format[vStrings] = s_version;
3813
3814
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&s_cversion,f,true))
3815 {
3816 return qe_invalid;
3817 }
3818
3819 //al_trace("Strings version %d\n", s_version);
3820 //section size
3821
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetl(&dummy_int,f,true))
3822 {
3823 return qe_invalid;
3824 }
3825
3826 //finally... section data
3827
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&temp_msg_count,f,true))
3828 {
3829 return qe_invalid;
3830 }
3831
3832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(temp_msg_count >= msg_strings_size)
3833 {
3834 Z_message("Reallocating string buffer...\n");
3835
3836 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3837 // return qe_nomem;
3838 delete[] MsgStrings;
3839 MsgStrings = new MsgStr[MAXMSGS];
3840 msg_strings_size = MAXMSGS;
3841 for(auto q = 0; q < msg_strings_size; ++q)
3842 {
3843 MsgStrings[q].clear();
3844 }
3845 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3846 }
3847
3848 //reset the message strings
3849
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(keepdata)
3850 {
3851
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if(s_version < 7)
3852
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 set_bit(quest_rules,qr_OLD_STRING_EDITOR_MARGINS,true);
3853
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 init_msgstrings(0,msg_strings_size);
3854 102 }
3855
3856 102 int32_t string_length=(s_version<2)?73:145;
3857
3858
2/2
✓ Branch 0 taken 10005 times.
✓ Branch 1 taken 102 times.
10107 for(int32_t i=0; i<temp_msg_count; i++)
3859 {
3860
1/2
✓ Branch 0 taken 10005 times.
✗ Branch 1 not taken.
10005 init_msgstr(&tempMsgString);
3861
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 9143 times.
10005 if(s_version > 8)
3862 {
3863
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&string_length,f,true))
3864 {
3865 return qe_invalid;
3866 }
3867 862 }
3868
2/2
✓ Branch 0 taken 9867 times.
✓ Branch 1 taken 138 times.
10005 if (string_length > 0)
3869 {
3870
2/4
✓ Branch 0 taken 9867 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9867 times.
✗ Branch 3 not taken.
9867 if (!pfread(buf, string_length, f, true))
3871 {
3872 return qe_invalid;
3873 }
3874 9867 }
3875 else
3876 {
3877 138 buf[0] = 0;
3878 }
3879
3880
2/4
✓ Branch 0 taken 10005 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10005 times.
✗ Branch 3 not taken.
10005 if(!p_igetw(&tempMsgString.nextstring,f,true))
3881 {
3882 return qe_invalid;
3883 }
3884
3885
2/2
✓ Branch 0 taken 4646 times.
✓ Branch 1 taken 5359 times.
10005 if(s_version<2)
3886 {
3887 4646 buf[72] = '\0';
3888
1/2
✓ Branch 0 taken 4646 times.
✗ Branch 1 not taken.
4646 tempMsgString.s = buf;
3889 4646 }
3890 else
3891 {
3892 // June 2008: A bug corrupted the last 4 chars of a string.
3893 // Discard these.
3894
1/2
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
5359 if(s_version<3)
3895 {
3896 for(int32_t j=140; j<144; j++)
3897 {
3898 buf[j] = '\0';
3899 }
3900 }
3901
1/2
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
5359 if(string_length > 8192) string_length = 8192;
3902 5359 buf[string_length]='\0'; //Force-terminate
3903
1/2
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
5359 tempMsgString.s = buf;
3904
3905
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 4497 times.
5359 if ( s_version >= 6 )
3906 {
3907
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&tempMsgString.tile,f,true))
3908 {
3909 return qe_invalid;
3910 }
3911 862 }
3912 else
3913 {
3914
2/4
✓ Branch 0 taken 4497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4497 times.
✗ Branch 3 not taken.
4497 if(!p_igetw(&tempMsgString.tile,f,true))
3915 {
3916 return qe_invalid;
3917 }
3918 }
3919
3920
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.cset,f,true))
3921 {
3922 return qe_invalid;
3923 }
3924
3925 byte dummy_char;
3926
3927
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&dummy_char,f,true)) // trans is stored as a char...
3928 {
3929 return qe_invalid;
3930 }
3931
3932 5359 tempMsgString.trans=dummy_char!=0;
3933
3934
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.font,f,true))
3935 {
3936 return qe_invalid;
3937 }
3938
3939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5359 times.
5359 if(s_version < 5)
3940 {
3941 if(!p_getc(&tempMsgString.y,f,true))
3942 {
3943 return qe_invalid;
3944 }
3945 }
3946 else
3947 {
3948
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_igetw(&tempMsgString.x,f,true))
3949 {
3950 return qe_invalid;
3951 }
3952
3953
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_igetw(&tempMsgString.y,f,true))
3954 {
3955 return qe_invalid;
3956 }
3957
3958
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_igetw(&tempMsgString.w,f,true))
3959 {
3960 return qe_invalid;
3961 }
3962
3963
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_igetw(&tempMsgString.h,f,true))
3964 {
3965 return qe_invalid;
3966 }
3967
3968
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.hspace,f,true))
3969 {
3970 return qe_invalid;
3971 }
3972
3973
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.vspace,f,true))
3974 {
3975 return qe_invalid;
3976 }
3977
3978
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.stringflags,f,true))
3979 {
3980 return qe_invalid;
3981 }
3982 }
3983
3984
2/2
✓ Branch 0 taken 4497 times.
✓ Branch 1 taken 862 times.
5359 if(s_version >= 7)
3985 {
3986
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 3448 times.
4310 for(int32_t q = 0; q < 4; ++q)
3987 {
3988
2/4
✓ Branch 0 taken 3448 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3448 times.
✗ Branch 3 not taken.
3448 if(!p_getc(&tempMsgString.margins[q],f,true))
3989 {
3990 return qe_invalid;
3991 }
3992 3448 }
3993
3994
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_igetl(&tempMsgString.portrait_tile,f,true))
3995 {
3996 return qe_invalid;
3997 }
3998
3999
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_cset,f,true))
4000 {
4001 return qe_invalid;
4002 }
4003
4004
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_x,f,true))
4005 {
4006 return qe_invalid;
4007 }
4008
4009
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_y,f,true))
4010 {
4011 return qe_invalid;
4012 }
4013
4014
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_tw,f,true))
4015 {
4016 return qe_invalid;
4017 }
4018
4019
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.portrait_th,f,true))
4020 {
4021 return qe_invalid;
4022 }
4023 862 }
4024
4025
2/2
✓ Branch 0 taken 862 times.
✓ Branch 1 taken 4497 times.
5359 if(s_version >= 8)
4026 {
4027
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.shadow_type,f,true))
4028 {
4029 return qe_invalid;
4030 }
4031
4032
2/4
✓ Branch 0 taken 862 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 862 times.
✗ Branch 3 not taken.
862 if(!p_getc(&tempMsgString.shadow_color,f,true))
4033 {
4034 return qe_invalid;
4035 }
4036 862 }
4037
4038
2/2
✓ Branch 0 taken 745 times.
✓ Branch 1 taken 4614 times.
5359 if(s_version >= 10)
4039 {
4040
2/4
✓ Branch 0 taken 745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 745 times.
✗ Branch 3 not taken.
745 if(!p_getc(&tempMsgString.drawlayer,f,true))
4041 {
4042 return qe_invalid;
4043 }
4044 745 }
4045
4046
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_getc(&tempMsgString.sfx,f,true))
4047 {
4048 return qe_invalid;
4049 }
4050
4051
1/2
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
5359 if(s_version>3)
4052 {
4053
2/4
✓ Branch 0 taken 5359 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5359 times.
✗ Branch 3 not taken.
5359 if(!p_igetw(&tempMsgString.listpos,f,true))
4054 {
4055 return qe_invalid;
4056 }
4057 5359 }
4058 }
4059
4060
1/2
✓ Branch 0 taken 10005 times.
✗ Branch 1 not taken.
10005 if(keepdata==true)
4061 {
4062
1/2
✓ Branch 0 taken 10005 times.
✗ Branch 1 not taken.
10005 MsgStrings[i].copyAll(tempMsgString);
4063 10005 }
4064 10005 }
4065 }
4066
4067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4068 {
4069 104 msg_count=temp_msg_count;
4070 104 }
4071
4072 104 return 0;
4073 104 }
4074
4075 104 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header, bool keepdata)
4076 {
4077
2/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version < 0x192)||
4078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4079 {
4080 2 return 0;
4081 }
4082
4083 102 word temp_door_combo_set_count=0;
4084 DoorComboSet tempDoorComboSet;
4085 word dummy_word;
4086 int32_t dummy_long;
4087 byte padding;
4088 102 int32_t s_version = 0;
4089
4090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(keepdata==true)
4091 {
4092
2/2
✓ Branch 0 taken 26112 times.
✓ Branch 1 taken 102 times.
26214 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4093 {
4094 26112 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4095 26112 }
4096 102 }
4097
4098
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(Header->zelda_version > 0x192)
4099 {
4100 //section version info
4101
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
4102 {
4103 return qe_invalid;
4104 }
4105
4106 102 FFCore.quest_format[vDoors] = s_version;
4107
4108 //al_trace("Door combo sets version %d\n", dummy_word);
4109
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy_word,f,true))
4110 {
4111 return qe_invalid;
4112 }
4113
4114 //section size
4115
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy_long,f,true))
4116 {
4117 return qe_invalid;
4118 }
4119 102 }
4120
4121 //finally... section data
4122
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&temp_door_combo_set_count,f,true))
4123 {
4124 return qe_invalid;
4125 }
4126
4127
2/2
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 102 times.
866 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4128 {
4129 764 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4130
4131 //name
4132
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f,true))
4133 {
4134 return qe_invalid;
4135 }
4136
4137
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(Header->zelda_version < 0x193)
4138 {
4139 if(!p_getc(&padding,f,true))
4140 {
4141 return qe_invalid;
4142 }
4143 }
4144
4145 //up door
4146
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4147 {
4148
2/2
✓ Branch 0 taken 27504 times.
✓ Branch 1 taken 6876 times.
34380 for(int32_t k=0; k<4; k++)
4149 {
4150
1/2
✓ Branch 0 taken 27504 times.
✗ Branch 1 not taken.
27504 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f,true))
4151 {
4152 return qe_invalid;
4153 }
4154 27504 }
4155 6876 }
4156
4157
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4158 {
4159
2/2
✓ Branch 0 taken 27504 times.
✓ Branch 1 taken 6876 times.
34380 for(int32_t k=0; k<4; k++)
4160 {
4161
1/2
✓ Branch 0 taken 27504 times.
✗ Branch 1 not taken.
27504 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f,true))
4162 {
4163 return qe_invalid;
4164 }
4165 27504 }
4166 6876 }
4167
4168 //down door
4169
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4170 {
4171
2/2
✓ Branch 0 taken 27504 times.
✓ Branch 1 taken 6876 times.
34380 for(int32_t k=0; k<4; k++)
4172 {
4173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27504 times.
27504 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f,true))
4174 {
4175 return qe_invalid;
4176 }
4177 27504 }
4178 6876 }
4179
4180
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4181 {
4182
2/2
✓ Branch 0 taken 27504 times.
✓ Branch 1 taken 6876 times.
34380 for(int32_t k=0; k<4; k++)
4183 {
4184
1/2
✓ Branch 0 taken 27504 times.
✗ Branch 1 not taken.
27504 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f,true))
4185 {
4186 return qe_invalid;
4187 }
4188 27504 }
4189 6876 }
4190
4191 //left door
4192
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4193 {
4194
2/2
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 6876 times.
48132 for(int32_t k=0; k<6; k++)
4195 {
4196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41256 times.
41256 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f,true))
4197 {
4198 return qe_invalid;
4199 }
4200 41256 }
4201 6876 }
4202
4203
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4204 {
4205
2/2
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 6876 times.
48132 for(int32_t k=0; k<6; k++)
4206 {
4207
1/2
✓ Branch 0 taken 41256 times.
✗ Branch 1 not taken.
41256 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f,true))
4208 {
4209 return qe_invalid;
4210 }
4211 41256 }
4212 6876 }
4213
4214 //right door
4215
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4216 {
4217
2/2
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 6876 times.
48132 for(int32_t k=0; k<6; k++)
4218 {
4219
1/2
✓ Branch 0 taken 41256 times.
✗ Branch 1 not taken.
41256 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f,true))
4220 {
4221 return qe_invalid;
4222 }
4223 41256 }
4224 6876 }
4225
4226
2/2
✓ Branch 0 taken 6876 times.
✓ Branch 1 taken 764 times.
7640 for(int32_t j=0; j<9; j++)
4227 {
4228
2/2
✓ Branch 0 taken 41256 times.
✓ Branch 1 taken 6876 times.
48132 for(int32_t k=0; k<6; k++)
4229 {
4230
1/2
✓ Branch 0 taken 41256 times.
✗ Branch 1 not taken.
41256 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f,true))
4231 {
4232 return qe_invalid;
4233 }
4234 41256 }
4235 6876 }
4236
4237 //up bomb rubble
4238
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 764 times.
2292 for(int32_t j=0; j<2; j++)
4239 {
4240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1528 times.
1528 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f,true))
4241 {
4242 return qe_invalid;
4243 }
4244 1528 }
4245
4246
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 764 times.
2292 for(int32_t j=0; j<2; j++)
4247 {
4248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1528 times.
1528 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f,true))
4249 {
4250 return qe_invalid;
4251 }
4252 1528 }
4253
4254 //down bomb rubble
4255
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 764 times.
2292 for(int32_t j=0; j<2; j++)
4256 {
4257
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1528 times.
1528 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f,true))
4258 {
4259 return qe_invalid;
4260 }
4261 1528 }
4262
4263
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 764 times.
2292 for(int32_t j=0; j<2; j++)
4264 {
4265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1528 times.
1528 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f,true))
4266 {
4267 return qe_invalid;
4268 }
4269 1528 }
4270
4271 //left bomb rubble
4272
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 764 times.
3056 for(int32_t j=0; j<3; j++)
4273 {
4274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2292 times.
2292 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f,true))
4275 {
4276 return qe_invalid;
4277 }
4278 2292 }
4279
4280
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 764 times.
3056 for(int32_t j=0; j<3; j++)
4281 {
4282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2292 times.
2292 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f,true))
4283 {
4284 return qe_invalid;
4285 }
4286 2292 }
4287
4288
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(Header->zelda_version < 0x193)
4289 {
4290 if(!p_getc(&padding,f,true))
4291 {
4292 return qe_invalid;
4293 }
4294
4295 }
4296
4297 //right bomb rubble
4298
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 764 times.
3056 for(int32_t j=0; j<3; j++)
4299 {
4300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2292 times.
2292 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f,true))
4301 {
4302 return qe_invalid;
4303 }
4304 2292 }
4305
4306
2/2
✓ Branch 0 taken 2292 times.
✓ Branch 1 taken 764 times.
3056 for(int32_t j=0; j<3; j++)
4307 {
4308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2292 times.
2292 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f,true))
4309 {
4310 return qe_invalid;
4311 }
4312 2292 }
4313
4314
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(Header->zelda_version < 0x193)
4315 {
4316 if(!p_getc(&padding,f,true))
4317 {
4318 return qe_invalid;
4319 }
4320 }
4321
4322 //walkthrough stuff
4323
2/2
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 764 times.
3820 for(int32_t j=0; j<4; j++)
4324 {
4325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3056 times.
3056 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f,true))
4326 {
4327 return qe_invalid;
4328 }
4329 3056 }
4330
4331
2/2
✓ Branch 0 taken 3056 times.
✓ Branch 1 taken 764 times.
3820 for(int32_t j=0; j<4; j++)
4332 {
4333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3056 times.
3056 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f,true))
4334 {
4335 return qe_invalid;
4336 }
4337 3056 }
4338
4339 //flags
4340
2/2
✓ Branch 0 taken 1528 times.
✓ Branch 1 taken 764 times.
2292 for(int32_t j=0; j<2; j++)
4341 {
4342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1528 times.
1528 if(!p_getc(&tempDoorComboSet.flags[j],f,true))
4343 {
4344 return qe_invalid;
4345 }
4346 1528 }
4347
4348
1/2
✓ Branch 0 taken 764 times.
✗ Branch 1 not taken.
764 if(Header->zelda_version < 0x193)
4349 {
4350 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f,true))
4351 {
4352 return qe_invalid;
4353 }
4354 }
4355
4356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 764 times.
764 if(keepdata==true)
4357 {
4358 764 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4359 764 }
4360 764 }
4361
4362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(keepdata==true)
4363 {
4364 102 door_combo_set_count=temp_door_combo_set_count;
4365 102 }
4366
4367 102 return 0;
4368 104 }
4369
4370 int32_t count_dmaps()
4371 {
4372 int32_t i=MAXDMAPS-1;
4373 bool found=false;
4374
4375 while(i>=0 && !found)
4376 {
4377 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4378 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4379 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4380 found=true;
4381
4382 for(int32_t j=0; j<8; j++)
4383 {
4384 if(DMaps[i].grid[j]!=0)
4385
4386 found=true;
4387 }
4388
4389 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4390 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4391 found=true;
4392
4393 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4394 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4395 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4396 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4397 found=true;
4398
4399 if(!found)
4400 {
4401 i--;
4402 }
4403 }
4404
4405 return i+1;
4406 }
4407
4408
4409 int32_t count_shops(miscQdata *Misc)
4410 {
4411 int32_t i=255,j;
4412 bool found=false;
4413
4414 while(i>=0 && !found)
4415 {
4416 j=2;
4417
4418 while(j>=0 && !found)
4419 {
4420 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4421 {
4422 found=true;
4423 }
4424 else
4425 {
4426 j--;
4427 }
4428 }
4429
4430 if(Misc->shop[i].name[0]!=0)
4431 {
4432 found=true;
4433 }
4434
4435 if(!found)
4436 {
4437 i--;
4438 }
4439 }
4440
4441 return i+1;
4442 }
4443
4444 int32_t count_infos(miscQdata *Misc)
4445 {
4446 int32_t i=255,j;
4447 bool found=false;
4448
4449 while(i>=0 && !found)
4450 {
4451 j=2;
4452
4453 while(j>=0 && !found)
4454 {
4455 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4456 {
4457 found=true;
4458 }
4459 else
4460 {
4461 j--;
4462 }
4463 }
4464
4465 if(Misc->info[i].name[0]!=0)
4466 {
4467 found=true;
4468 }
4469
4470 if(!found)
4471 {
4472 i--;
4473 }
4474 }
4475
4476 return i+1;
4477 }
4478
4479 int32_t count_warprings(miscQdata *Misc)
4480 {
4481 int32_t i=15,j;
4482 bool found=false;
4483
4484 while(i>=0 && !found)
4485 {
4486 j=7;
4487
4488 while(j>=0 && !found)
4489 {
4490 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4491 {
4492 found=true;
4493 }
4494 else
4495 {
4496 j--;
4497 }
4498 }
4499
4500 if(!found)
4501 {
4502 i--;
4503 }
4504 }
4505
4506 return i+1;
4507 }
4508
4509 int32_t count_palcycles(miscQdata *Misc)
4510 {
4511 int32_t i=255,j;
4512 bool found=false;
4513
4514 while(i>=0 && !found)
4515 {
4516 j=2;
4517
4518 while(j>=0 && !found)
4519 {
4520 if(Misc->cycles[i][j].count!=0)
4521 {
4522 found=true;
4523 }
4524 else
4525 {
4526 j--;
4527 }
4528 }
4529
4530 if(!found)
4531 {
4532 i--;
4533 }
4534 }
4535
4536 return i+1;
4537 }
4538
4539 178840 void clear_screen(mapscr *temp_scr)
4540 {
4541 178840 temp_scr->zero_memory();
4542 178840 }
4543
4544 104 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps, bool keepdata)
4545 {
4546 104 word dmapstoread=0;
4547 dmap tempDMap;
4548
4549 int32_t dummy;
4550 104 word s_version=0, s_cversion=0;
4551 byte padding;
4552
4553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
4554 {
4555
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<max_dmaps; i++)
4556 {
4557 53248 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4558 53248 sprintf(DMaps[start_dmap+i].title," ");
4559 53248 sprintf(DMaps[start_dmap+i].intro," ");
4560 53248 DMaps[start_dmap+i].type |= dmCAVE;
4561 53248 }
4562 104 }
4563
4564
3/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 2 times.
104 if(!Header || Header->zelda_version > 0x192)
4565 {
4566 //section version info
4567
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
4568 {
4569 return qe_invalid;
4570 }
4571
4572 102 FFCore.quest_format[vDMaps] = s_version;
4573
4574 //al_trace("DMaps version %d\n", s_version);
4575
4576
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f,true))
4577 {
4578 return qe_invalid;
4579 }
4580
4581 //section size
4582
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
4583 {
4584 return qe_invalid;
4585 }
4586
4587 //finally... section data
4588
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dmapstoread,f,true))
4589 {
4590 return qe_invalid;
4591 }
4592 102 }
4593 else
4594 {
4595
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((Header->zelda_version < 0x192)||
4596 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4597 {
4598 2 dmapstoread=32;
4599 2 }
4600 else if(s_version <= 4)
4601 {
4602 dmapstoread=OLDMAXDMAPS;
4603 }
4604 else
4605 {
4606 dmapstoread=MAXDMAPS;
4607 }
4608 }
4609
4610
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 dmapstoread=zc_min(dmapstoread, max_dmaps);
4611
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4612
4613
2/2
✓ Branch 0 taken 51008 times.
✓ Branch 1 taken 104 times.
51112 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4614 {
4615 51008 memset(&tempDMap,0,sizeof(dmap));
4616 51008 sprintf(tempDMap.title," ");
4617 51008 sprintf(tempDMap.intro," ");
4618
4619
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.map,f,keepdata))
4620 {
4621 return qe_invalid;
4622 }
4623
4624
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 49664 times.
51008 if(s_version <= 4)
4625 {
4626 byte tempbyte;
4627
4628
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(!p_getc(&tempbyte,f,keepdata))
4629 {
4630 return qe_invalid;
4631 }
4632
4633 1344 tempDMap.level=(word)tempbyte;
4634 1344 }
4635 else
4636 {
4637
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&tempDMap.level,f,keepdata))
4638 {
4639 return qe_invalid;
4640 }
4641 }
4642
4643
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.xoff,f,keepdata))
4644 {
4645 return qe_invalid;
4646 }
4647
4648
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.compass,f,keepdata))
4649 {
4650 return qe_invalid;
4651 }
4652
4653
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 1344 times.
51008 if(s_version > 8) // February 2009
4654 {
4655
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&tempDMap.color,f,true))
4656 {
4657 return qe_invalid;
4658 }
4659 49664 }
4660 else
4661 {
4662 byte tempbyte;
4663
4664
1/2
✓ Branch 0 taken 1344 times.
✗ Branch 1 not taken.
1344 if(!p_getc(&tempbyte,f,true))
4665 {
4666 return qe_invalid;
4667 }
4668
4669 1344 tempDMap.color = (word)tempbyte;
4670 }
4671
4672
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.midi,f,keepdata))
4673 {
4674 return qe_invalid;
4675 }
4676
4677
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.cont,f,keepdata))
4678 {
4679 return qe_invalid;
4680 }
4681
4682
1/2
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
51008 if(!p_getc(&tempDMap.type,f,keepdata))
4683 {
4684 return qe_invalid;
4685 }
4686
4687
4/4
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 50598 times.
✓ Branch 2 taken 402 times.
✓ Branch 3 taken 8 times.
51418 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4688
1/2
✓ Branch 0 taken 410 times.
✗ Branch 1 not taken.
410 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4689 402 tempDMap.xoff = 0;
4690
4691
2/2
✓ Branch 0 taken 408064 times.
✓ Branch 1 taken 51008 times.
459072 for(int32_t j=0; j<8; j++)
4692 {
4693
1/2
✓ Branch 0 taken 408064 times.
✗ Branch 1 not taken.
408064 if(!p_getc(&tempDMap.grid[j],f,keepdata))
4694 {
4695 return qe_invalid;
4696 }
4697 408064 }
4698
4699
4/8
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 50944 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
51008 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4700 {
4701
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 18 times.
64 if(tempDMap.level>0&&tempDMap.level<10)
4702 {
4703 18 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4704 18 }
4705
4706
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
64 if(i==0 && Header->zelda_version <= 0x190)
4707 {
4708 2 tempDMap.cont-=tempDMap.xoff;
4709 2 tempDMap.compass-=tempDMap.xoff;
4710 2 }
4711
4712 //forgotten -DD
4713
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 46 times.
64 if(tempDMap.level==0)
4714 {
4715 46 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4716 46 }
4717 64 }
4718 else
4719 {
4720
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f,true))
4721 {
4722 return qe_invalid;
4723 }
4724
4725
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f,true))
4726 {
4727 return qe_invalid;
4728 }
4729
4730
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f,true))
4731 {
4732 return qe_invalid;
4733 }
4734
4735
3/8
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 50944 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
50944 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4736 {
4737 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4738 if(keepdata==true)
4739 {
4740 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4741 }
4742
4743 continue;
4744 }
4745
4746
2/4
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✗ Branch 3 not taken.
50944 if(Header && (Header->zelda_version < 0x193))
4747 {
4748 if(!p_getc(&padding,f,keepdata))
4749 {
4750 return qe_invalid;
4751 }
4752 }
4753
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39168 times.
50944 if ( s_version >= 11 )
4754 {
4755
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.minimap_1_tile,f,keepdata))
4756 {
4757 return qe_invalid;
4758 }
4759 11776 }
4760 else
4761 {
4762
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempDMap.minimap_1_tile,f,keepdata))
4763 {
4764 return qe_invalid;
4765 }
4766 }
4767
4768
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!p_getc(&tempDMap.minimap_1_cset,f,keepdata))
4769 {
4770 return qe_invalid;
4771 }
4772
4773
2/4
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✗ Branch 3 not taken.
50944 if(Header && (Header->zelda_version < 0x193))
4774 {
4775 if(!p_getc(&padding,f,keepdata))
4776 {
4777 return qe_invalid;
4778 }
4779 }
4780
4781
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39168 times.
50944 if ( s_version >= 11 )
4782 {
4783
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.minimap_2_tile,f,keepdata))
4784 {
4785 return qe_invalid;
4786 }
4787 11776 }
4788 else
4789 {
4790
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempDMap.minimap_2_tile,f,keepdata))
4791 {
4792 return qe_invalid;
4793 }
4794 }
4795
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!p_getc(&tempDMap.minimap_2_cset,f,keepdata))
4796 {
4797 return qe_invalid;
4798 }
4799
4800
2/4
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✗ Branch 3 not taken.
50944 if(Header && (Header->zelda_version < 0x193))
4801 {
4802 if(!p_getc(&padding,f,keepdata))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
4808
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39168 times.
50944 if ( s_version >= 11 )
4809 {
4810
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.largemap_1_tile,f,keepdata))
4811 {
4812 return qe_invalid;
4813 }
4814 11776 }
4815 else
4816 {
4817
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempDMap.largemap_1_tile,f,keepdata))
4818 {
4819 return qe_invalid;
4820 }
4821 }
4822
4823
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!p_getc(&tempDMap.largemap_1_cset,f,keepdata))
4824 {
4825 return qe_invalid;
4826 }
4827
4828
2/4
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 50944 times.
✗ Branch 3 not taken.
50944 if(Header && (Header->zelda_version < 0x193))
4829 {
4830
4831 if(!p_getc(&padding,f,keepdata))
4832 {
4833 return qe_invalid;
4834 }
4835 }
4836
4837
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39168 times.
50944 if ( s_version >= 11 )
4838 {
4839
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempDMap.largemap_2_tile,f,keepdata))
4840 {
4841 return qe_invalid;
4842 }
4843 11776 }
4844 else
4845 {
4846
1/2
✓ Branch 0 taken 39168 times.
✗ Branch 1 not taken.
39168 if(!p_igetw(&tempDMap.largemap_2_tile,f,keepdata))
4847 {
4848 return qe_invalid;
4849 }
4850 }
4851
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!p_getc(&tempDMap.largemap_2_cset,f,keepdata))
4852 {
4853 return qe_invalid;
4854 }
4855
4856
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f,true))
4857 {
4858 return qe_invalid;
4859 }
4860 }
4861
4862
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 49664 times.
51008 if(s_version>1)
4863 {
4864
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&tempDMap.tmusictrack,f,keepdata))
4865 {
4866 return qe_invalid;
4867 }
4868
4869
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&tempDMap.active_subscreen,f,keepdata))
4870 {
4871 return qe_invalid;
4872 }
4873
4874
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&tempDMap.passive_subscreen,f,keepdata))
4875 {
4876 return qe_invalid;
4877 }
4878 49664 }
4879
4880
2/2
✓ Branch 0 taken 1344 times.
✓ Branch 1 taken 49664 times.
51008 if(s_version>2)
4881 {
4882 byte di[32];
4883
4884
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!pfread(&di, 32, f, true)) return qe_invalid;
4885
4886
2/2
✓ Branch 0 taken 12713984 times.
✓ Branch 1 taken 49664 times.
12763648 for(int32_t j=0; j<MAXITEMS; j++)
4887 {
4888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12713984 times.
12713984 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4889 12713984 else tempDMap.disableditems[j]=0;
4890 12713984 }
4891 49664 }
4892
4893
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 1344 times.
51008 if(s_version >= 6)
4894 {
4895
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&tempDMap.flags,f,keepdata))
4896 {
4897 return qe_invalid;
4898 }
4899 49664 }
4900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1344 times.
1344 else if(s_version>3)
4901 {
4902 char temp;
4903
4904 if(!p_getc(&temp,f,keepdata))
4905 {
4906 return qe_invalid;
4907 }
4908
4909 tempDMap.flags = temp;
4910 }
4911
3/8
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 691 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 653 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1344 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4912 {
4913 653 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4914 653 }
4915 else
4916 691 tempDMap.flags=0;
4917
4918
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 1344 times.
51008 if(s_version<7)
4919 {
4920
3/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 691 times.
✓ Branch 2 taken 653 times.
✗ Branch 3 not taken.
1344 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4921 653 tempDMap.flags|= dmfVIEWMAP;
4922 1344 }
4923
4924
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 1344 times.
51008 if(s_version<8)
4925 {
4926
4/4
✓ Branch 0 taken 653 times.
✓ Branch 1 taken 691 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 569 times.
1344 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4927 {
4928 569 tempDMap.type &= ~dmDNGN;
4929 569 tempDMap.type |= dmCAVE;
4930 569 }
4931
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 467 times.
775 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4932 {
4933 467 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4934 467 }
4935 1344 }
4936
4937
5/8
✓ Branch 0 taken 51008 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64 times.
✓ Branch 3 taken 50944 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 64 times.
✓ Branch 6 taken 50944 times.
✗ Branch 7 not taken.
51008 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4938 50944 && (Header->zelda_version < 0x193))
4939 {
4940 if(!p_getc(&padding,f,keepdata))
4941 {
4942 return qe_invalid;
4943 }
4944 }
4945
4946
2/2
✓ Branch 0 taken 39232 times.
✓ Branch 1 taken 11776 times.
51008 if(s_version >= 10)
4947 {
4948
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempDMap.sideview,f,keepdata))
4949 {
4950 return qe_invalid;
4951 }
4952 11776 }
4953
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if(s_version < 10) tempDMap.sideview = 0;
4954
4955 //Dmap Scripts
4956
2/2
✓ Branch 0 taken 39232 times.
✓ Branch 1 taken 11776 times.
51008 if(s_version >= 12)
4957 {
4958
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.script,f,keepdata))
4959 {
4960 return qe_invalid;
4961 }
4962
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
4963 {
4964
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.initD[q],f,keepdata))
4965 {
4966 return qe_invalid;
4967 }
4968 94208 }
4969 11776 }
4970
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if ( s_version < 12 )
4971 {
4972 39232 tempDMap.script = 0;
4973
2/2
✓ Branch 0 taken 313856 times.
✓ Branch 1 taken 39232 times.
353088 for ( int32_t q = 0; q < 8; q++ )
4974 {
4975 313856 tempDMap.initD[q] = 0;
4976 313856 }
4977 39232 }
4978
4979
2/2
✓ Branch 0 taken 39232 times.
✓ Branch 1 taken 11776 times.
51008 if(s_version >= 13)
4980 {
4981
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
4982 {
4983
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
4984 {
4985
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.initD_label[q][w],f,keepdata))
4986 {
4987 return qe_invalid;
4988 }
4989 6123520 }
4990 94208 }
4991 11776 }
4992
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if ( s_version < 13 )
4993 {
4994 39232 tempDMap.script = 0;
4995
2/2
✓ Branch 0 taken 313856 times.
✓ Branch 1 taken 39232 times.
353088 for ( int32_t q = 0; q < 8; q++ )
4996 {
4997
2/2
✓ Branch 0 taken 20400640 times.
✓ Branch 1 taken 313856 times.
20714496 for ( int32_t w = 0; w < 65; w++ )
4998 20400640 tempDMap.initD_label[q][w] = 0;
4999 313856 }
5000 39232 }
5001
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if(s_version >= 14)
5002 {
5003
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.active_sub_script,f,keepdata))
5004 {
5005 return qe_invalid;
5006 }
5007
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.passive_sub_script,f,keepdata))
5008 {
5009 return qe_invalid;
5010 }
5011
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; ++q )
5012 {
5013
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.sub_initD[q],f,keepdata))
5014 {
5015 return qe_invalid;
5016 }
5017 94208 }
5018
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for(int32_t q = 0; q < 8; ++q)
5019 {
5020
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; ++w )
5021 {
5022
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.sub_initD_label[q][w],f,keepdata))
5023 {
5024 return qe_invalid;
5025 }
5026 6123520 }
5027 94208 }
5028 11776 }
5029 else
5030 {
5031 39232 tempDMap.active_sub_script = 0;
5032 39232 tempDMap.passive_sub_script = 0;
5033
2/2
✓ Branch 0 taken 313856 times.
✓ Branch 1 taken 39232 times.
353088 for(int32_t q = 0; q < 8; ++q)
5034 {
5035 313856 tempDMap.sub_initD[q] = 0;
5036
2/2
✓ Branch 0 taken 20400640 times.
✓ Branch 1 taken 313856 times.
20714496 for(int32_t w = 0; w < 65; ++w)
5037 20400640 tempDMap.sub_initD_label[q][w] = 0;
5038 313856 }
5039 }
5040
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if(s_version >= 15)
5041 {
5042
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempDMap.onmap_script,f,keepdata))
5043 {
5044 return qe_invalid;
5045 }
5046
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; ++q )
5047 {
5048
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&tempDMap.onmap_initD[q],f,keepdata))
5049 {
5050 return qe_invalid;
5051 }
5052 94208 }
5053
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for(int32_t q = 0; q < 8; ++q)
5054 {
5055
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; ++w )
5056 {
5057
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f,keepdata))
5058 {
5059 return qe_invalid;
5060 }
5061 6123520 }
5062 94208 }
5063 11776 }
5064 else
5065 {
5066 39232 tempDMap.onmap_script = 0;
5067
2/2
✓ Branch 0 taken 313856 times.
✓ Branch 1 taken 39232 times.
353088 for(int32_t q = 0; q < 8; ++q)
5068 {
5069 313856 tempDMap.onmap_initD[q] = 0;
5070
2/2
✓ Branch 0 taken 20400640 times.
✓ Branch 1 taken 313856 times.
20714496 for(int32_t w = 0; w < 65; ++w)
5071 {
5072 20400640 tempDMap.onmap_initD_label[q][w] = 0;
5073 20400640 }
5074 313856 }
5075 }
5076
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 39232 times.
51008 if(s_version >= 16)
5077 {
5078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11776 times.
11776 if(!p_igetw(&tempDMap.mirrorDMap,f,keepdata))
5079 {
5080 return qe_invalid;
5081 }
5082 11776 }
5083 else
5084 {
5085 39232 tempDMap.mirrorDMap = -1;
5086 }
5087
5088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51008 times.
51008 if(keepdata==true)
5089 {
5090 51008 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5091 51008 }
5092 51008 }
5093
5094 104 return 0;
5095 104 }
5096
5097 97 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5098 {
5099 //these are here to bypass compiler warnings about unused arguments
5100 97 Header=Header;
5101
5102 miscQdata temp_misc;
5103 97 word s_version=0, s_cversion=0;
5104 97 int32_t tempsize=0;
5105 word dummyw;
5106
5107 97 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5108
5109 //section version info
5110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
5111 {
5112 return qe_invalid;
5113 }
5114
5115 97 FFCore.quest_format[vColours] = s_version;
5116
5117 97 al_trace("Misc Colours section version: %d\n", s_version);
5118
5119 //al_trace("Misc. colors version %d\n", s_version);
5120
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
5121 {
5122 return qe_invalid;
5123 }
5124
5125
5126 //section size
5127
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&tempsize,f,true))
5128 {
5129 return qe_invalid;
5130 }
5131
5132 //finally... section data
5133 97 readsize=0;
5134
5135
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.text,f,true))
5136 {
5137 return qe_invalid;
5138 }
5139
5140
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.caption,f,true))
5141 {
5142 return qe_invalid;
5143 }
5144
5145
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5146 {
5147 return qe_invalid;
5148 }
5149
5150
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5151 {
5152 return qe_invalid;
5153 }
5154
5155
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5156 {
5157 return qe_invalid;
5158 }
5159
5160
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5161 {
5162 return qe_invalid;
5163 }
5164
5165
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5166 {
5167 return qe_invalid;
5168 }
5169
5170
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5171 {
5172 return qe_invalid;
5173 }
5174
5175
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5176 {
5177 return qe_invalid;
5178 }
5179
5180
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5181 {
5182 return qe_invalid;
5183 }
5184
5185
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5186 {
5187 return qe_invalid;
5188 }
5189
5190
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5191 {
5192 return qe_invalid;
5193 }
5194
5195
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5196 {
5197 return qe_invalid;
5198 }
5199
5200
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5201 {
5202 return qe_invalid;
5203 }
5204
5205
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5206 {
5207 return qe_invalid;
5208 }
5209
5210
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5211 {
5212 return qe_invalid;
5213 }
5214
5215
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5216 {
5217 return qe_invalid;
5218 }
5219
5220
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5221 {
5222 return qe_invalid;
5223 }
5224
5225
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5226 {
5227 return qe_invalid;
5228 }
5229
5230
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5231 {
5232 return qe_invalid;
5233 }
5234
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if(s_version < 4)
5235 {
5236
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5237 return qe_invalid;
5238 74 temp_misc.colors.triforce_tile = dummyw;
5239
5240
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5241 return qe_invalid;
5242 74 temp_misc.colors.triframe_tile = dummyw;
5243
5244
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5245 return qe_invalid;
5246 74 temp_misc.colors.overworld_map_tile = dummyw;
5247
5248
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5249 return qe_invalid;
5250 74 temp_misc.colors.dungeon_map_tile = dummyw;
5251
5252
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5253 return qe_invalid;
5254 74 temp_misc.colors.blueframe_tile = dummyw;
5255
5256
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&dummyw,f,true))
5257 return qe_invalid;
5258 74 temp_misc.colors.HCpieces_tile = dummyw;
5259 74 }
5260
5261
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5262 {
5263 return qe_invalid;
5264 }
5265
5266
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5267 {
5268 return qe_invalid;
5269 }
5270
5271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version < 2)
5272 {
5273 temp_misc.colors.msgtext = 0x01;
5274 }
5275 else
5276 {
5277
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_getc(&temp_misc.colors.msgtext, f, true))
5278 {
5279 return qe_invalid;
5280 }
5281 }
5282
5283
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if ( s_version >= 3 ) //expanded tile pages to 825
5284 {
5285
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.triforce_tile,f,true))
5286 {
5287 return qe_invalid;
5288 }
5289
5290
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.triframe_tile,f,true))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f,true))
5296 {
5297 return qe_invalid;
5298 }
5299
5300
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f,true))
5301 {
5302 return qe_invalid;
5303 }
5304
5305
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.colors.blueframe_tile,f,true))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f,true))
5311 {
5312 return qe_invalid;
5313 }
5314 23 }
5315
5316
5317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata==true)
5318 {
5319 97 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5320 97 }
5321
5322 97 return 0;
5323 97 }
5324
5325 97 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc, bool keepdata)
5326 {
5327 miscQdata temp_misc;
5328 97 word s_version=0, s_cversion=0;
5329 byte icons;
5330 97 int32_t tempsize=0;
5331
5332 97 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5333
5334 //section version info
5335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
5336 {
5337 return qe_invalid;
5338 }
5339
5340 97 FFCore.quest_format[vIcons] = s_version;
5341
5342 //al_trace("Game icons version %d\n", s_version);
5343
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
5344 {
5345 return qe_invalid;
5346 }
5347
5348
5349 //section size
5350
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&tempsize,f,true))
5351 {
5352 return qe_invalid;
5353 }
5354
5355 //finally... section data
5356 97 readsize=0;
5357
5358 97 icons=4;
5359
5360
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if ( s_version >= 10 )
5361 {
5362
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<icons; i++)
5363 {
5364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&temp_misc.icons[i],f,true))
5365 {
5366 return qe_invalid;
5367 }
5368 92 }
5369 23 }
5370 else
5371 {
5372
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<icons; i++)
5373 {
5374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(!p_igetw(&temp_misc.icons[i],f,true))
5375 {
5376 return qe_invalid;
5377 }
5378 296 }
5379 }
5380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata==true)
5381 {
5382 97 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5383 97 }
5384
5385 97 return 0;
5386 97 }
5387
5388 104 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc, bool keepdata)
5389 {
5390 104 word maxinfos=256;
5391 104 word maxshops=256;
5392 104 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5393 104 word ponds=16, pondsize=72, expansionsize=98*2;
5394 byte tempbyte, padding;
5395 miscQdata temp_misc;
5396 104 word s_version=0, s_cversion=0;
5397 word swaptmp;
5398 104 int32_t tempsize=0;
5399
5400 104 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5401
5402
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<maxshops; ++i)
5403 {
5404 26624 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5405 26624 }
5406
5407
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<maxinfos; ++i)
5408 {
5409 26624 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5410 26624 }
5411
5412
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
5413 {
5414 //section version info
5415
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
5416 {
5417 return qe_invalid;
5418 }
5419
5420 102 FFCore.quest_format[vMisc] = s_version;
5421
5422 //al_trace("Misc. data version %d\n", s_version);
5423
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f,true))
5424 {
5425 return qe_invalid;
5426 }
5427
5428
5429 //section size
5430
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&tempsize,f,true))
5431 {
5432 return qe_invalid;
5433 }
5434 102 }
5435
5436 //finally... section data
5437 104 readsize=0;
5438
5439 //shops
5440
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
5441 {
5442
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&shops,f,true))
5443 {
5444 return qe_invalid;
5445 }
5446 102 }
5447
5448
2/2
✓ Branch 0 taken 1080 times.
✓ Branch 1 taken 104 times.
1184 for(int32_t i=0; i<shops; i++)
5449 {
5450
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 994 times.
1080 if(s_version > 6)
5451 {
5452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 994 times.
994 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f,true))
5453 {
5454 return qe_invalid;
5455 }
5456 994 }
5457
5458
2/2
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 1080 times.
4320 for(int32_t j=0; j<3; j++)
5459 {
5460
1/2
✓ Branch 0 taken 3240 times.
✗ Branch 1 not taken.
3240 if(!p_getc(&temp_misc.shop[i].item[j],f,true))
5461 {
5462 return qe_invalid;
5463 }
5464
5465
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 258 times.
3240 if(s_version < 4)
5466 {
5467 258 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5468 258 }
5469 3240 }
5470
5471
2/2
✓ Branch 0 taken 1048 times.
✓ Branch 1 taken 32 times.
1080 if(Header->zelda_version < 0x193)
5472 {
5473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f,true))
5474 {
5475 return qe_invalid;
5476 }
5477 32 }
5478
5479
2/2
✓ Branch 0 taken 3240 times.
✓ Branch 1 taken 1080 times.
4320 for(int32_t j=0; j<3; j++)
5480 {
5481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3240 times.
3240 if(!p_igetw(&temp_misc.shop[i].price[j],f,true))
5482 {
5483 return qe_invalid;
5484 }
5485 3240 }
5486
5487
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 994 times.
1080 if(s_version > 3)
5488 {
5489
2/2
✓ Branch 0 taken 2982 times.
✓ Branch 1 taken 994 times.
3976 for(int32_t j=0; j<3; j++)
5490 {
5491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2982 times.
2982 if(!p_getc(&temp_misc.shop[i].hasitem[j],f,true))
5492 return qe_invalid;
5493 2982 }
5494 994 }
5495
5496 /*
5497 if(s_version < 8)
5498 {
5499 for(int32_t j=0; j<3; j++)
5500 {
5501 (&temp_misc.shop[i].str[j])=0; //initialise.
5502 }
5503 }
5504 */
5505 1080 }
5506
5507 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5508
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<maxshops; ++i)
5509 {
5510
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 26624 times.
79872 for(int32_t j=0; j<3-1; j++)
5511 {
5512
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 53248 times.
133120 for(int32_t k=0; k<2-j; k++)
5513 {
5514
2/2
✓ Branch 0 taken 2306 times.
✓ Branch 1 taken 77566 times.
79872 if(temp_misc.shop[i].hasitem[k]==0)
5515 {
5516 77566 swaptmp = temp_misc.shop[i].item[k];
5517 77566 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5518 77566 temp_misc.shop[i].item[k+1] = swaptmp;
5519 77566 swaptmp = temp_misc.shop[i].price[k];
5520 77566 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5521 77566 temp_misc.shop[i].price[k+1] = swaptmp;
5522 77566 swaptmp = temp_misc.shop[i].hasitem[k];
5523 77566 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5524 77566 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5525 77566 }
5526 79872 }
5527 53248 }
5528 26624 }
5529
5530 //infos
5531
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
5532 {
5533
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&infos,f,true))
5534 {
5535 return qe_invalid;
5536 }
5537 102 }
5538
5539
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 104 times.
1591 for(int32_t i=0; i<infos; i++)
5540 {
5541
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 1440 times.
1487 if(s_version > 6)
5542 {
5543
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1440 times.
1440 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f,true))
5544 {
5545 return qe_invalid;
5546 }
5547 1440 }
5548
5549
2/2
✓ Branch 0 taken 4461 times.
✓ Branch 1 taken 1487 times.
5948 for(int32_t j=0; j<3; j++)
5550 {
5551
2/4
✓ Branch 0 taken 4365 times.
✓ Branch 1 taken 96 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4461 if((Header->zelda_version < 0x192)||
5552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4365 times.
4365 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5553 {
5554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&tempbyte,f,true))
5555 {
5556 return qe_invalid;
5557 }
5558
5559 96 temp_misc.info[i].str[j]=tempbyte;
5560 96 }
5561 else
5562 {
5563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4365 times.
4365 if(!p_igetw(&temp_misc.info[i].str[j],f,true))
5564 {
5565 return qe_invalid;
5566 }
5567 }
5568 4461 }
5569
5570
2/2
✓ Branch 0 taken 1455 times.
✓ Branch 1 taken 32 times.
1487 if(Header->zelda_version < 0x193)
5571 {
5572
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&tempbyte,f,true))
5573 {
5574 return qe_invalid;
5575 }
5576 32 }
5577
5578
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1487 if((Header->zelda_version == 0x192)&&(Header->build>145))
5579 {
5580 if(!p_getc(&padding,f,true))
5581 {
5582 return qe_invalid;
5583 }
5584 }
5585
5586
2/2
✓ Branch 0 taken 4461 times.
✓ Branch 1 taken 1487 times.
5948 for(int32_t j=0; j<3; j++)
5587 {
5588
1/2
✓ Branch 0 taken 4461 times.
✗ Branch 1 not taken.
4461 if(!p_igetw(&temp_misc.info[i].price[j],f,true))
5589 {
5590 return qe_invalid;
5591 }
5592 4461 }
5593 1487 }
5594
5595 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5596
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<maxinfos; ++i)
5597 {
5598
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 26624 times.
79872 for(int32_t j=0; j<3-1; j++)
5599 {
5600
2/2
✓ Branch 0 taken 79872 times.
✓ Branch 1 taken 53248 times.
133120 for(int32_t k=0; k<2-j; k++)
5601 {
5602
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 78108 times.
79872 if(temp_misc.info[i].str[k]==0)
5603 {
5604 78108 swaptmp = temp_misc.info[i].str[k];
5605 78108 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5606 78108 temp_misc.info[i].str[k+1] = swaptmp;
5607 78108 swaptmp = temp_misc.info[i].price[k];
5608 78108 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5609 78108 temp_misc.info[i].price[k+1] = swaptmp;
5610 78108 }
5611 79872 }
5612 53248 }
5613 26624 }
5614
5615
5616 //warp rings
5617
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(s_version > 5)
5618 97 warprings++;
5619
5620
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
5621 {
5622
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&warprings,f,true))
5623 {
5624 return qe_invalid;
5625 }
5626 102 }
5627
5628
2/2
✓ Branch 0 taken 1015 times.
✓ Branch 1 taken 104 times.
1119 for(int32_t i=0; i<warprings; i++)
5629 {
5630
2/2
✓ Branch 0 taken 9039 times.
✓ Branch 1 taken 1015 times.
10054 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5631 {
5632
2/2
✓ Branch 0 taken 768 times.
✓ Branch 1 taken 8271 times.
9039 if(s_version <= 3)
5633 {
5634
1/2
✓ Branch 0 taken 768 times.
✗ Branch 1 not taken.
768 if(!p_getc(&tempbyte,f,true))
5635 {
5636 return qe_invalid;
5637 }
5638
5639 768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5640 768 }
5641 else
5642 {
5643
1/2
✓ Branch 0 taken 8271 times.
✗ Branch 1 not taken.
8271 if(!p_igetw(&temp_misc.warp[i].dmap[j],f,true))
5644 {
5645 return qe_invalid;
5646 }
5647 }
5648 9039 }
5649
5650
2/2
✓ Branch 0 taken 9039 times.
✓ Branch 1 taken 1015 times.
10054 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5651 {
5652
1/2
✓ Branch 0 taken 9039 times.
✗ Branch 1 not taken.
9039 if(!p_getc(&temp_misc.warp[i].scr[j],f,true))
5653 {
5654 return qe_invalid;
5655 }
5656 9039 }
5657
5658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1015 times.
1015 if(!p_getc(&temp_misc.warp[i].size,f,true))
5659 {
5660 return qe_invalid;
5661 }
5662
5663
2/2
✓ Branch 0 taken 999 times.
✓ Branch 1 taken 16 times.
1015 if(Header->zelda_version < 0x193)
5664 {
5665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(!p_getc(&tempbyte,f,true))
5666 {
5667 return qe_invalid;
5668 }
5669 16 }
5670 1015 }
5671
5672 //palette cycles
5673
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5674 {
5675
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 2 times.
514 for(int32_t i=0; i<256; i++)
5676 {
5677
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 512 times.
2048 for(int32_t j=0; j<3; j++)
5678 {
5679 1536 temp_misc.cycles[i][j].first=0;
5680 1536 temp_misc.cycles[i][j].count=0;
5681 1536 temp_misc.cycles[i][j].speed=0;
5682 1536 }
5683 512 }
5684
5685
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2 if((Header->zelda_version < 0x192)||
5686 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5687 {
5688 2 palcycles=16;
5689 2 }
5690
5691
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
34 for(int32_t i=0; i<palcycles; i++)
5692 {
5693
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 32 times.
128 for(int32_t j=0; j<3; j++)
5694 {
5695
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
5696 {
5697 return qe_invalid;
5698 }
5699
5700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
5701 {
5702 return qe_invalid;
5703 }
5704
5705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
5706 {
5707 return qe_invalid;
5708 }
5709 96 }
5710 32 }
5711 2 }
5712
5713 //Wind warps are now just another warp ring.
5714
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version <= 5)
5715 {
5716
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
7 if(Header->zelda_version > 0x192)
5717 {
5718
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(!p_igetw(&windwarps,f,true))
5719 {
5720 return qe_invalid;
5721 }
5722 5 }
5723
5724
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 7 times.
68 for(int32_t i=0; i<windwarps; i++)
5725 {
5726
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(s_version <= 3)
5727 {
5728
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(!p_getc(&tempbyte,f,true))
5729 {
5730 return qe_invalid;
5731 }
5732
5733 61 temp_misc.warp[8].dmap[i]=tempbyte;
5734 61 }
5735 else
5736 {
5737 if(!p_igetw(&temp_misc.warp[8].dmap[i],f,true))
5738 {
5739 return qe_invalid;
5740 }
5741 }
5742
5743
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61 times.
61 if(!p_getc(&temp_misc.warp[8].scr[i],f,true))
5744 {
5745 return qe_invalid;
5746 }
5747
5748 61 temp_misc.warp[8].size = 9;
5749
5750
1/2
✓ Branch 0 taken 61 times.
✗ Branch 1 not taken.
61 if(s_version == 5)
5751 {
5752 if(!p_getc(&tempbyte,f,true))
5753 {
5754 return qe_invalid;
5755 }
5756 }
5757 61 }
5758 7 }
5759
5760
5761 //triforce pieces
5762
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 104 times.
936 for(int32_t i=0; i<triforces; i++)
5763 {
5764
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 if(!p_getc(&temp_misc.triforce[i],f,true))
5765 {
5766 return qe_invalid;
5767 }
5768 832 }
5769
5770 //misc color data
5771
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<3)
5772 {
5773
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.text,f,true))
5774 {
5775 return qe_invalid;
5776 }
5777
5778
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.caption,f,true))
5779 {
5780 return qe_invalid;
5781 }
5782
5783
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.overw_bg,f,true))
5784 {
5785 return qe_invalid;
5786 }
5787
5788
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.dngn_bg,f,true))
5789 {
5790 return qe_invalid;
5791 }
5792
5793
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.dngn_fg,f,true))
5794 {
5795 return qe_invalid;
5796 }
5797
5798
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.cave_fg,f,true))
5799 {
5800 return qe_invalid;
5801 }
5802
5803
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.bs_dk,f,true))
5804 {
5805 return qe_invalid;
5806 }
5807
5808
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.bs_goal,f,true))
5809 {
5810 return qe_invalid;
5811 }
5812
5813
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.compass_lt,f,true))
5814 {
5815 return qe_invalid;
5816 }
5817
5818
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.compass_dk,f,true))
5819 {
5820 return qe_invalid;
5821 }
5822
5823
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.subscr_bg,f,true))
5824 {
5825 return qe_invalid;
5826 }
5827
5828
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.triframe_color,f,true))
5829 {
5830 return qe_invalid;
5831 }
5832
5833
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.hero_dot,f,true))
5834 {
5835 return qe_invalid;
5836 }
5837
5838
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.bmap_bg,f,true))
5839 {
5840 return qe_invalid;
5841 }
5842
5843
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.bmap_fg,f,true))
5844 {
5845 return qe_invalid;
5846 }
5847
5848
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.triforce_cset,f,true))
5849 {
5850 return qe_invalid;
5851 }
5852
5853
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.triframe_cset,f,true))
5854 {
5855 return qe_invalid;
5856 }
5857
5858
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.overworld_map_cset,f,true))
5859 {
5860 return qe_invalid;
5861 }
5862
5863
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f,true))
5864 {
5865 return qe_invalid;
5866 }
5867
5868
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.blueframe_cset,f,true))
5869 {
5870 return qe_invalid;
5871 }
5872
5873
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.triforce_tile,f,true))
5874 {
5875 return qe_invalid;
5876 }
5877
5878
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.triframe_tile,f,true))
5879 {
5880 return qe_invalid;
5881 }
5882
5883
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f,true))
5884 {
5885 return qe_invalid;
5886 }
5887
5888
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f,true))
5889 {
5890 return qe_invalid;
5891 }
5892
5893
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.blueframe_tile,f,true))
5894 {
5895 return qe_invalid;
5896 }
5897
5898
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f,true))
5899 {
5900 return qe_invalid;
5901 }
5902
5903
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_misc.colors.HCpieces_cset,f,true))
5904 {
5905 return qe_invalid;
5906 }
5907
5908 7 temp_misc.colors.msgtext = 0x01;
5909
5910
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(Header->zelda_version < 0x193)
5911 {
5912
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2 times.
16 for(int32_t i=0; i<7; i++)
5913 {
5914
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(!p_getc(&tempbyte,f,true))
5915 {
5916 return qe_invalid;
5917 }
5918 14 }
5919 2 }
5920
5921
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if((Header->zelda_version == 0x192)&&(Header->build>145))
5922 {
5923 for(int32_t i=0; i<256; i++)
5924 {
5925 if(!p_getc(&tempbyte,f,true))
5926 {
5927 return qe_invalid;
5928 }
5929 }
5930 }
5931
5932
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(s_version>1)
5933 {
5934 if(!p_getc(&temp_misc.colors.subscr_shadow,f,true))
5935 {
5936 return qe_invalid;
5937 }
5938 }
5939
5940 //save game icons
5941
2/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 if((Header->zelda_version < 0x192)||
5942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5943 {
5944 2 icons=3;
5945 2 }
5946
5947
2/2
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 7 times.
33 for(int32_t i=0; i<icons; i++)
5948 {
5949
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 if(!p_igetw(&temp_misc.icons[i],f,true))
5950 {
5951 return qe_invalid;
5952 }
5953 26 }
5954 7 }
5955
5956
2/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version < 0x192)||
5957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ((Header->zelda_version == 0x192)&&(Header->build<30)))
5958 {
5959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata==true)
5960 {
5961 2 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5962 2 }
5963
5964 2 return 0;
5965 }
5966
5967 //pond information
5968
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(Header->zelda_version < 0x193)
5969 {
5970 if((Header->zelda_version == 0x192)&&(Header->build<146))
5971 {
5972 pondsize=25;
5973 }
5974
5975 for(int32_t i=0; i<ponds; i++)
5976 {
5977 for(int32_t j=0; j<pondsize; j++)
5978 {
5979 if(!p_getc(&tempbyte,f,true))
5980 {
5981 return qe_invalid;
5982
5983 }
5984 }
5985 }
5986 }
5987
5988 //end string
5989
1/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if((Header->zelda_version < 0x192)||
5990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5991 {
5992 if(!p_getc(&tempbyte,f,true))
5993 {
5994 return qe_invalid;
5995 }
5996
5997 temp_misc.endstring=tempbyte;
5998
5999 if(!p_getc(&tempbyte,f,true))
6000 {
6001 return qe_invalid;
6002 }
6003 }
6004 else
6005 {
6006
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&temp_misc.endstring,f,true))
6007 {
6008 return qe_invalid;
6009 }
6010 }
6011
6012 //expansion
6013
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(Header->zelda_version < 0x193)
6014 {
6015 if((Header->zelda_version == 0x192)&&(Header->build<73))
6016 {
6017 expansionsize=99*2;
6018 }
6019
6020 for(int32_t i=0; i<expansionsize; i++)
6021 {
6022 if(!p_getc(&tempbyte,f,true))
6023 {
6024 return qe_invalid;
6025 }
6026 }
6027 }
6028 //shops v8
6029
6030
6031
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if(s_version >= 8)
6032 {
6033
2/2
✓ Branch 0 taken 336 times.
✓ Branch 1 taken 23 times.
359 for(int32_t i=0; i<shops; i++)
6034 {
6035
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for(int32_t j=0; j<3; j++)
6036 {
6037
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!p_igetw(&temp_misc.shop[i].str[j],f,true))
6038 return qe_invalid;
6039 1008 }
6040 336 }
6041 23 }
6042
6043 102 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6044 102 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6045 102 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6046
6047 //v9 includes quest misc[32]
6048
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if(s_version >= 9)
6049 {
6050
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 23 times.
759 for ( int32_t q = 0; q < 32; q++ )
6051 {
6052
1/2
✓ Branch 0 taken 736 times.
✗ Branch 1 not taken.
736 if(!p_igetl(&temp_misc.questmisc[q],f,true))
6053 return qe_invalid;
6054 736 }
6055
2/2
✓ Branch 0 taken 736 times.
✓ Branch 1 taken 23 times.
759 for ( int32_t q = 0; q < 32; q++ )
6056 {
6057
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 736 times.
94944 for ( int32_t j = 0; j < 128; j++ )
6058
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_getc(&temp_misc.questmisc_strings[q][j],f,true))
6059 return qe_invalid;
6060 736 }
6061 23 }
6062
6063
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if(s_version >= 11 )
6064 {
6065
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f,true))
6066 return qe_invalid;
6067 23 }
6068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 else if(s_version < 11 )
6069 {
6070 79 temp_misc.zscript_last_compiled_version = -1;
6071 79 }
6072
6073 102 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6074
6075
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if(s_version >= 12)
6076 {
6077 byte spr;
6078
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t q = 0; q < sprMAX; ++q)
6079 {
6080
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&spr,f,true))
6081 return qe_invalid;
6082 5888 temp_misc.sprites[q] = spr;
6083 5888 }
6084 23 }
6085 else
6086 {
6087 79 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6088 //temp_misc.sprites[sprFALL] = ;
6089 }
6090
6091
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if(s_version >= 13)
6092 {
6093
2/2
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 23 times.
1495 for(size_t q = 0; q < 64; ++q)
6094 {
6095 1472 bottletype* bt = &(temp_misc.bottle_types[q]);
6096
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!pfread(bt->name, 32, f, true))
6097 return qe_invalid;
6098
2/2
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 1472 times.
5888 for(size_t j = 0; j < 3; ++j)
6099 {
6100
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if (!p_getc(&(bt->counter[j]), f, true))
6101 return qe_invalid;
6102
1/2
✓ Branch 0 taken 4416 times.
✗ Branch 1 not taken.
4416 if (!p_igetw(&(bt->amount[j]), f, true))
6103 return qe_invalid;
6104 4416 }
6105
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!p_getc(&(bt->flags), f, true))
6106 return qe_invalid;
6107
1/2
✓ Branch 0 taken 1472 times.
✗ Branch 1 not taken.
1472 if (!p_getc(&(bt->next_type), f, true))
6108 return qe_invalid;
6109 1472 }
6110
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(size_t q = 0; q < 256; ++q)
6111 {
6112 5888 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6113
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if (!pfread(bst->name, 32, f, true))
6114 return qe_invalid;
6115
2/2
✓ Branch 0 taken 17664 times.
✓ Branch 1 taken 5888 times.
23552 for(size_t j = 0; j < 3; ++j)
6116 {
6117
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_getc(&(bst->fill[j]), f, true))
6118 return qe_invalid;
6119
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->comb[j]), f, true))
6120 return qe_invalid;
6121
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_getc(&(bst->cset[j]), f, true))
6122 return qe_invalid;
6123
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->price[j]), f, true))
6124 return qe_invalid;
6125
1/2
✓ Branch 0 taken 17664 times.
✗ Branch 1 not taken.
17664 if (!p_igetw(&(bst->str[j]), f, true))
6126 return qe_invalid;
6127 17664 }
6128 5888 }
6129 23 }
6130 else
6131 {
6132
2/2
✓ Branch 0 taken 5056 times.
✓ Branch 1 taken 79 times.
5135 for(size_t q = 0; q < 64; ++q)
6133 5056 temp_misc.bottle_types[q].clear();
6134
2/2
✓ Branch 0 taken 20224 times.
✓ Branch 1 taken 79 times.
20303 for(size_t q = 0; q < 256; ++q)
6135 20224 temp_misc.bottle_shop_types[q].clear();
6136 }
6137
6138
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if(s_version >= 14)
6139 {
6140 byte msfx;
6141
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t q = 0; q < sfxMAX; ++q)
6142 {
6143
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&msfx,f,true))
6144 return qe_invalid;
6145 5888 temp_misc.miscsfx[q] = msfx;
6146 5888 }
6147 23 }
6148 else
6149 {
6150 79 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6151 79 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6152 79 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6153 }
6154
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if(s_version < 15)
6155 {
6156 79 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6157 79 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6158 79 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6159 79 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6160 79 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6161 79 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6162 79 }
6163
6164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(keepdata==true)
6165 {
6166 102 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6167 102 }
6168
6169 102 return 0;
6170 104 }
6171
6172 extern char *item_string[ITEMCNT];
6173 extern const char *old_item_string[iLast];
6174 extern char *weapon_string[WPNCNT];
6175 extern const char *old_weapon_string[wLast];
6176
6177 104 int32_t readitems(PACKFILE *f, word version, word build, bool keepdata, bool zgpmode)
6178 {
6179 byte padding;
6180 int32_t dummy;
6181 104 word items_to_read=MAXITEMS;
6182 itemdata tempitem;
6183 104 word s_version=0, s_cversion=0;
6184 word dummy_word;
6185
6186
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(version < 0x186)
6187 {
6188 items_to_read=64;
6189 }
6190
6191
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(version > 0x192)
6192 {
6193 102 items_to_read=0;
6194
6195 //section version info
6196
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
6197 {
6198 return qe_invalid;
6199 }
6200
6201 102 FFCore.quest_format[vItems] = s_version;
6202
6203 //al_trace("Items version %d\n", s_version);
6204
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f,true))
6205 {
6206 return qe_invalid;
6207 }
6208
6209 //section size
6210
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
6211 {
6212 return qe_invalid;
6213 }
6214
6215 //finally... section data
6216
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&items_to_read,f,true))
6217 {
6218 return qe_invalid;
6219 }
6220 102 }
6221
6222
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version>1)
6223 {
6224
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i=0; i<items_to_read; i++)
6225 {
6226 char tempname[64];
6227
6228
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!pfread(tempname, 64, f, keepdata))
6229 {
6230 return qe_invalid;
6231 }
6232
6233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(keepdata)
6234 {
6235 24832 strcpy(item_string[i], tempname);
6236 24832 }
6237 24832 }
6238 97 }
6239 else
6240 {
6241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(keepdata)
6242 {
6243
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<ITEMCNT; i++)
6244 {
6245 1792 reset_itemname(i);
6246 1792 }
6247 7 }
6248 }
6249
6250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
6251 {
6252
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXITEMS; i++)
6253 {
6254 26624 itemdata& id = itemsbuf[i];
6255 26624 memset(&id, 0, sizeof(itemdata));
6256 26624 id.count=-1;
6257 26624 id.playsound=WAV_SCALE;
6258 26624 reset_itembuf(&id,i);
6259 26624 }
6260 104 }
6261
6262
2/2
✓ Branch 0 taken 25694 times.
✓ Branch 1 taken 104 times.
25798 for(int32_t i=0; i<items_to_read; i++)
6263 {
6264 25694 memset(&tempitem, 0, sizeof(itemdata));
6265 25694 reset_itembuf(&tempitem,i);
6266
6267
6268
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 19806 times.
25694 if ( s_version > 35 ) //expanded tiles
6269 {
6270
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tile,f,true))
6271 {
6272 return qe_invalid;
6273 }
6274 5888 }
6275 else
6276 {
6277
1/2
✓ Branch 0 taken 19806 times.
✗ Branch 1 not taken.
19806 if(!p_igetw(&tempitem.tile,f,true))
6278 {
6279 return qe_invalid;
6280 }
6281 }
6282
6283
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(!p_getc(&tempitem.misc_flags,f,true))
6284 {
6285 return qe_invalid;
6286 }
6287
6288
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(!p_getc(&tempitem.csets,f,true))
6289 {
6290 return qe_invalid;
6291 }
6292
6293
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(!p_getc(&tempitem.frames,f,true))
6294 {
6295 return qe_invalid;
6296 }
6297
6298
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(!p_getc(&tempitem.speed,f,true))
6299 {
6300 return qe_invalid;
6301 }
6302
6303
1/2
✓ Branch 0 taken 25694 times.
✗ Branch 1 not taken.
25694 if(!p_getc(&tempitem.delay,f,true))
6304 {
6305 return qe_invalid;
6306 }
6307
6308
2/2
✓ Branch 0 taken 25182 times.
✓ Branch 1 taken 512 times.
25694 if(version < 0x193)
6309 {
6310
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&padding,f,true))
6311 {
6312 return qe_invalid;
6313 }
6314
6315
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
512 if((version < 0x192)||((version == 0x192)&&(build<186)))
6316 {
6317
3/3
✓ Branch 0 taken 508 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 2 times.
512 switch(i)
6318 {
6319 case iShield:
6320 2 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-12:10;
6321 2 break;
6322
6323 case iMShield:
6324 2 tempitem.ltm=get_bit(quest_rules,qr_BSZELDA)?-6:-10;
6325 2 break;
6326
6327 default:
6328 508 tempitem.ltm=0;
6329 508 break;
6330 }
6331
6332 512 tempitem.count=-1;
6333 512 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6334 512 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6335 512 tempitem.family=0xFF;
6336 512 tempitem.playsound=WAV_SCALE;
6337 512 reset_itembuf(&tempitem,i);
6338
6339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 if(keepdata==true)
6340 {
6341 512 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6342 512 }
6343
6344 512 continue;
6345 }
6346 }
6347
6348
1/2
✓ Branch 0 taken 25182 times.
✗ Branch 1 not taken.
25182 if(!p_igetl(&tempitem.ltm,f,true))
6349 {
6350 return qe_invalid;
6351 }
6352
6353
1/2
✓ Branch 0 taken 25182 times.
✗ Branch 1 not taken.
25182 if(version < 0x193)
6354 {
6355 for(int32_t q=0; q<12; q++)
6356 {
6357 if(!p_getc(&padding,f,true))
6358 {
6359 return qe_invalid;
6360 }
6361 }
6362 }
6363
6364
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 350 times.
25182 if(s_version>1)
6365 {
6366
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 18944 times.
24832 if ( s_version >= 31 )
6367 {
6368
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.family,f,true))
6369 {
6370 return qe_invalid;
6371 }
6372 5888 }
6373 else
6374 {
6375
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.family,f,true))
6376 {
6377 return qe_invalid;
6378 }
6379 }
6380
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version < 16)
6381 if(tempitem.family == 0xFF)
6382 tempitem.family = itype_misc;
6383
6384
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.fam_type,f,true))
6385 {
6386 return qe_invalid;
6387 }
6388
6389
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version>5)
6390 {
6391
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 18944 times.
24832 if(s_version>=31)
6392 {
6393
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.power,f,true))
6394 {
6395 return qe_invalid;
6396 }
6397 5888 }
6398 else
6399 {
6400
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempitem.power,f,true))
6401 {
6402 return qe_invalid;
6403 }
6404 }
6405
6406 //converted flags from 16b to 32b -Z
6407
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version < 41 )
6408 {
6409
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_igetw(&tempitem.flags,f,true))
6410 {
6411 return qe_invalid;
6412 }
6413 18944 }
6414 else
6415 {
6416
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.flags,f,true))
6417 {
6418 return qe_invalid;
6419 }
6420 }
6421 24832 }
6422 else
6423 {
6424 //tempitem.power = tempitem.fam_type;
6425 char tempchar;
6426
6427 if(!p_getc(&tempchar,f,true))
6428 {
6429 return qe_invalid;
6430 }
6431
6432 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6433 }
6434
6435
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetw(&tempitem.script,f,true))
6436 {
6437 return qe_invalid;
6438 }
6439
6440
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version<=3)
6441 {
6442 if(tempitem.script > NUMSCRIPTITEM)
6443 {
6444 tempitem.script = 0;
6445 }
6446 }
6447
6448
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.count,f,true))
6449 {
6450 return qe_invalid;
6451 }
6452
6453
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetw(&tempitem.amount,f,true))
6454 {
6455 return qe_invalid;
6456 }
6457
6458
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetw(&tempitem.collect_script,f,true))
6459 {
6460 return qe_invalid;
6461 }
6462
6463
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version<=3)
6464 {
6465 if(tempitem.collect_script > NUMSCRIPTITEM)
6466 {
6467 tempitem.collect_script = 0;
6468 }
6469 }
6470
6471
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetw(&tempitem.setmax,f,true))
6472 {
6473 return qe_invalid;
6474 }
6475
6476
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetw(&tempitem.max,f,true))
6477 {
6478 return qe_invalid;
6479 }
6480
6481
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.playsound,f,true))
6482 {
6483 return qe_invalid;
6484 }
6485
6486
2/2
✓ Branch 0 taken 198656 times.
✓ Branch 1 taken 24832 times.
223488 for(int32_t j=0; j<8; j++)
6487 {
6488
1/2
✓ Branch 0 taken 198656 times.
✗ Branch 1 not taken.
198656 if(!p_igetl(&tempitem.initiald[j],f,true))
6489 {
6490 return qe_invalid;
6491 }
6492 198656 }
6493
6494
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 24832 times.
74496 for(int32_t j=0; j<2; j++)
6495 {
6496
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&tempitem.initiala[j],f,true))
6497 {
6498 return qe_invalid;
6499 }
6500 49664 }
6501
6502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(s_version>4)
6503 {
6504
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version>5)
6505 {
6506
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn,f,true))
6507 {
6508 return qe_invalid;
6509 }
6510
6511
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn2,f,true))
6512 {
6513 return qe_invalid;
6514 }
6515
6516
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn3,f,true))
6517 {
6518 return qe_invalid;
6519 }
6520
6521
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn4,f,true))
6522 {
6523 return qe_invalid;
6524 }
6525
6526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(s_version>=15)
6527 {
6528
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn5,f,true))
6529 {
6530 return qe_invalid;
6531 }
6532
6533
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn6,f,true))
6534 {
6535 return qe_invalid;
6536 }
6537
6538
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn7,f,true))
6539 {
6540 return qe_invalid;
6541 }
6542
6543
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn8,f,true))
6544 {
6545 return qe_invalid;
6546 }
6547
6548
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn9,f,true))
6549 {
6550 return qe_invalid;
6551 }
6552
6553
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.wpn10,f,true))
6554 {
6555 return qe_invalid;
6556 }
6557 24832 }
6558
6559
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.pickup_hearts,f,true))
6560 {
6561 return qe_invalid;
6562 }
6563
6564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(s_version<15)
6565 {
6566 if(!p_igetw(&dummy_word,f,true))
6567 {
6568 return qe_invalid;
6569 }
6570
6571 tempitem.misc1=dummy_word;
6572
6573 if(!p_igetw(&dummy_word,f,true))
6574 {
6575 return qe_invalid;
6576 }
6577
6578 tempitem.misc2=dummy_word;
6579 }
6580 else
6581 {
6582
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc1,f,true))
6583 {
6584 return qe_invalid;
6585 }
6586
6587
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc2,f,true))
6588 {
6589 return qe_invalid;
6590 }
6591
6592 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6593
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(s_version<24)
6594 {
6595 if(tempitem.family==itype_shield)
6596 {
6597 tempitem.misc1|=shSCRIPT;
6598 }
6599 }
6600 }
6601
6602
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if(s_version < 53)
6603 {
6604 byte tempbyte;
6605
1/2
✓ Branch 0 taken 18944 times.
✗ Branch 1 not taken.
18944 if(!p_getc(&tempbyte,f,true))
6606 {
6607 return qe_invalid;
6608 }
6609 18944 tempitem.cost_amount[0] = tempbyte;
6610 18944 }
6611 else
6612 {
6613
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < 2; ++q)
6614 {
6615
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&tempitem.cost_amount[q],f,true))
6616 {
6617 return qe_invalid;
6618 }
6619 11776 }
6620 }
6621 24832 }
6622 else
6623 {
6624 char tempchar;
6625
6626 if(!p_getc(&tempchar,f,true))
6627 {
6628 return qe_invalid;
6629 }
6630
6631 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6632 }
6633
6634 // June 2007: more misc. attributes
6635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(s_version>=12)
6636 {
6637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(s_version<15)
6638 {
6639 if(!p_igetw(&dummy_word,f,true))
6640 {
6641 return qe_invalid;
6642 }
6643
6644 tempitem.misc3=dummy_word;
6645
6646 if(!p_igetw(&dummy_word,f,true))
6647 {
6648 return qe_invalid;
6649 }
6650
6651 tempitem.misc4=dummy_word;
6652 }
6653 else
6654 {
6655
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc3,f,true))
6656 {
6657 return qe_invalid;
6658 }
6659
6660
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc4,f,true))
6661 {
6662 return qe_invalid;
6663 }
6664
6665
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc5,f,true))
6666 {
6667 return qe_invalid;
6668 }
6669
6670
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc6,f,true))
6671 {
6672 return qe_invalid;
6673 }
6674
6675
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc7,f,true))
6676 {
6677 return qe_invalid;
6678 }
6679
6680
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc8,f,true))
6681 {
6682 return qe_invalid;
6683 }
6684
6685
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc9,f,true))
6686 {
6687 return qe_invalid;
6688 }
6689
6690
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_igetl(&tempitem.misc10,f,true))
6691 {
6692 return qe_invalid;
6693 }
6694 }
6695
6696
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!p_getc(&tempitem.usesound,f,true))
6697 {
6698 return qe_invalid;
6699 }
6700
6701
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 18944 times.
24832 if(s_version >= 49)
6702 {
6703
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&tempitem.usesound2,f,true))
6704 {
6705 return qe_invalid;
6706 }
6707 5888 }
6708 18944 else tempitem.usesound2 = 0;
6709
6710
3/4
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
✓ Branch 2 taken 18944 times.
✗ Branch 3 not taken.
24832 if(s_version < 50 && tempitem.family == itype_mirror)
6711 {
6712 //Split continue/dmap warp effect/sfx, port for old
6713 tempitem.misc2 = tempitem.misc1;
6714 tempitem.usesound2 = tempitem.usesound;
6715 }
6716 24832 }
6717 24832 }
6718
6719
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6720 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6721
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&tempitem.useweapon,f,true))
6722 {
6723 return qe_invalid;
6724 }
6725
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&tempitem.usedefence,f,true))
6726 {
6727 return qe_invalid;
6728 }
6729
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weaprange,f,true))
6730 {
6731 return qe_invalid;
6732 }
6733
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weapduration,f,true))
6734 {
6735 return qe_invalid;
6736 }
6737
2/2
✓ Branch 0 taken 58880 times.
✓ Branch 1 taken 5888 times.
64768 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6738 {
6739
1/2
✓ Branch 0 taken 58880 times.
✗ Branch 1 not taken.
58880 if(!p_igetl(&tempitem.weap_pattern[q],f,true))
6740 {
6741 return qe_invalid;
6742 }
6743 58880 }
6744 5888 }
6745
6746
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6747 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6748
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.duplicates,f,true))
6749 {
6750 return qe_invalid;
6751 }
6752
2/2
✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 5888 times.
52992 for ( int32_t q = 0; q < INITIAL_D; q++ )
6753 {
6754
1/2
✓ Branch 0 taken 47104 times.
✗ Branch 1 not taken.
47104 if(!p_igetl(&tempitem.weap_initiald[q],f,true))
6755 {
6756 return qe_invalid;
6757 }
6758 47104 }
6759
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for ( int32_t q = 0; q < INITIAL_A; q++ )
6760 {
6761
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempitem.weap_initiala[q],f,true))
6762 {
6763 return qe_invalid;
6764 }
6765 11776 }
6766
6767
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&tempitem.drawlayer,f,true))
6768 {
6769 return qe_invalid;
6770 }
6771
6772
6773
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hxofs,f,true))
6774 {
6775 return qe_invalid;
6776 }
6777
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hyofs,f,true))
6778 {
6779 return qe_invalid;
6780 }
6781
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hxsz,f,true))
6782 {
6783 return qe_invalid;
6784 }
6785
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hysz,f,true))
6786 {
6787 return qe_invalid;
6788 }
6789
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.hzsz,f,true))
6790 {
6791 return qe_invalid;
6792 }
6793
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.xofs,f,true))
6794 {
6795 return qe_invalid;
6796 }
6797
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.yofs,f,true))
6798 {
6799 return qe_invalid;
6800 }
6801
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hxofs,f,true))
6802 {
6803 return qe_invalid;
6804 }
6805
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hyofs,f,true))
6806 {
6807 return qe_invalid;
6808 }
6809
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hxsz,f,true))
6810 {
6811 return qe_invalid;
6812 }
6813
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hysz,f,true))
6814 {
6815 return qe_invalid;
6816 }
6817
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_hzsz,f,true))
6818 {
6819 return qe_invalid;
6820 }
6821
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_xofs,f,true))
6822 {
6823 return qe_invalid;
6824 }
6825
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_yofs,f,true))
6826 {
6827 return qe_invalid;
6828 }
6829
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.weaponscript,f,true))
6830 {
6831 return qe_invalid;
6832 }
6833
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.wpnsprite,f,true))
6834 {
6835 return qe_invalid;
6836 }
6837 5888 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6838
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < num_cost_tmr; ++q)
6839 {
6840
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&tempitem.magiccosttimer[q],f,true))
6841 {
6842 return qe_invalid;
6843 }
6844 11776 }
6845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 for(auto q = num_cost_tmr; q < 2; ++q)
6846 tempitem.magiccosttimer[q] = 0;
6847 5888 }
6848
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6849 {
6850 //Item Size FLags, TileWidth, TileHeight
6851
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.overrideFLAGS,f,true))
6852 {
6853 return qe_invalid;
6854 }
6855
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tilew,f,true))
6856 {
6857 return qe_invalid;
6858 }
6859
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.tileh,f,true))
6860 {
6861 return qe_invalid;
6862 }
6863 5888 }
6864
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 29 ) //! More new vars.
6865 {
6866 //Item Size FLags, TileWidth, TileHeight
6867
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weapoverrideFLAGS,f,true))
6868 {
6869 return qe_invalid;
6870 }
6871
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_tilew,f,true))
6872 {
6873 return qe_invalid;
6874 }
6875
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.weap_tileh,f,true))
6876 {
6877 return qe_invalid;
6878 }
6879 5888 }
6880
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 30 ) //! More new vars.
6881 {
6882 //Pickup Type
6883
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempitem.pickup,f,true))
6884 {
6885 return qe_invalid;
6886 }
6887 5888 }
6888
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 32 ) //! More new vars.
6889 {
6890 //Pickup Type
6891
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.pstring,f,true))
6892 {
6893 return qe_invalid;
6894 }
6895 5888 }
6896
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 33 ) //! More new vars.
6897 {
6898 //Pickup Type
6899
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.pickup_string_flags,f,true))
6900 {
6901 return qe_invalid;
6902 }
6903 5888 }
6904
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 34 ) //! cost counter
6905 {
6906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5888 times.
5888 if(s_version < 53)
6907 {
6908 if(!p_getc(&tempitem.cost_counter[0],f,true))
6909 {
6910 return qe_invalid;
6911 }
6912 }
6913 else
6914 {
6915
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for(auto q = 0; q < 2; ++q)
6916 {
6917
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&tempitem.cost_counter[q],f,true))
6918 {
6919 return qe_invalid;
6920 }
6921 11776 }
6922 }
6923 5888 }
6924
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 44 ) //! sprite scripts
6925 {
6926
2/2
✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 5888 times.
52992 for ( int32_t q = 0; q < 8; q++ )
6927 {
6928
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
6929 {
6930
1/2
✓ Branch 0 taken 3061760 times.
✗ Branch 1 not taken.
3061760 if(!p_getc(&(tempitem.initD_label[q][w]),f,keepdata))
6931 {
6932 return qe_invalid;
6933 }
6934 3061760 }
6935
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
6936 {
6937
1/2
✓ Branch 0 taken 3061760 times.
✗ Branch 1 not taken.
3061760 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f,keepdata))
6938 {
6939 return qe_invalid;
6940 }
6941 3061760 }
6942
2/2
✓ Branch 0 taken 3061760 times.
✓ Branch 1 taken 47104 times.
3108864 for ( int32_t w = 0; w < 65; w++ )
6943 {
6944
1/2
✓ Branch 0 taken 3061760 times.
✗ Branch 1 not taken.
3061760 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f,keepdata))
6945 {
6946 return qe_invalid;
6947 }
6948 3061760 }
6949
1/2
✓ Branch 0 taken 47104 times.
✗ Branch 1 not taken.
47104 if(!p_igetl(&(tempitem.sprite_initiald[q]),f,keepdata))
6950 {
6951 return qe_invalid;
6952 }
6953
6954 47104 }
6955
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 5888 times.
17664 for ( int32_t q = 0; q < 2; q++ )
6956 {
6957
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempitem.sprite_initiala[q]),f,keepdata))
6958 {
6959 return qe_invalid;
6960 }
6961 11776 }
6962 //Pickup Type
6963
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempitem.sprite_script,f,true))
6964 {
6965 return qe_invalid;
6966 }
6967 5888 }
6968
2/2
✓ Branch 0 taken 18944 times.
✓ Branch 1 taken 5888 times.
24832 if ( s_version >= 48 ) //! pickup flags
6969 {
6970
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_getc(&(tempitem.pickupflag),f,keepdata))
6971 {
6972 return qe_invalid;
6973 }
6974 5888 }
6975 24832 }
6976 else
6977 {
6978 350 tempitem.count=-1;
6979 350 tempitem.family=itype_misc;
6980 350 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6981 350 tempitem.playsound=WAV_SCALE;
6982 350 reset_itembuf(&tempitem,i);
6983 }
6984
6985
1/2
✓ Branch 0 taken 25182 times.
✗ Branch 1 not taken.
25182 if(keepdata==true)
6986 {
6987 25182 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6988 25182 }
6989 else if(zgpmode)
6990 {
6991 itemsbuf[i].tile=tempitem.tile;
6992 itemsbuf[i].misc_flags=tempitem.misc_flags;
6993 itemsbuf[i].csets=tempitem.csets;
6994 itemsbuf[i].frames=tempitem.frames;
6995 itemsbuf[i].speed=tempitem.speed;
6996 itemsbuf[i].delay=tempitem.delay;
6997 itemsbuf[i].ltm=tempitem.ltm;
6998 }
6999 25182 }
7000
7001 //////////////////////////////////////////////////////
7002 // Now do any updates because of new item additions
7003 // (These can't be done above because items_to_read
7004 // might be too low.)
7005 //////////////////////////////////////////////////////
7006
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
7007 {
7008
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXITEMS; i++)
7009 {
7010 26624 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7011
7012 //Account for older quests that didn't have an actual item for the used letter
7013
4/4
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 24832 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 7 times.
26624 if(s_version < 2 && i==iLetterUsed)
7014 {
7015 7 reset_itembuf(&tempitem, iLetterUsed);
7016 7 strcpy(item_string[i],old_item_string[i]);
7017 7 tempitem.tile = itemsbuf[iLetter].tile;
7018 7 tempitem.csets = itemsbuf[iLetter].csets;
7019 7 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7020 7 tempitem.frames = itemsbuf[iLetter].frames;
7021 7 tempitem.speed = itemsbuf[iLetter].speed;
7022 7 tempitem.ltm = itemsbuf[iLetter].ltm;
7023 7 }
7024
7025
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 3)
7026 {
7027
3/3
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 1631 times.
✓ Branch 2 taken 7 times.
1792 switch(i)
7028 {
7029 case iRocsFeather:
7030 case iHoverBoots:
7031 case iSpinScroll:
7032 case iL2SpinScroll:
7033 case iCrossScroll:
7034 case iQuakeScroll:
7035 case iL2QuakeScroll:
7036 case iWhispRing:
7037 case iL2WhispRing:
7038 case iChargeRing:
7039 case iL2ChargeRing:
7040 case iPerilScroll:
7041 case iWalletL3:
7042 case iQuiverL4:
7043 case iBombBagL4:
7044 case iBracelet:
7045 case iL2Bracelet:
7046 case iOldGlove:
7047 case iL2Ladder:
7048 case iWealthMedal:
7049 case iL2WealthMedal:
7050 case iL3WealthMedal:
7051 154 reset_itembuf(&tempitem, i);
7052 154 strcpy(item_string[i],old_item_string[i]);
7053 154 break;
7054
7055 case iSShield:
7056 7 reset_itembuf(&tempitem, i);
7057 7 strcpy(item_string[i],old_item_string[i]);
7058 7 strcpy(item_string[iShield],old_item_string[iShield]);
7059 7 strcpy(item_string[iMShield],old_item_string[iMShield]);
7060 7 break;
7061 }
7062 1792 }
7063
7064
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 5)
7065 {
7066
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 1743 times.
1792 switch(i)
7067 {
7068 case iHeartRing:
7069 case iL2HeartRing:
7070 case iL3HeartRing:
7071 case iMagicRing:
7072 case iL2MagicRing:
7073 case iL3MagicRing:
7074 case iL4MagicRing:
7075 49 reset_itembuf(&tempitem, i);
7076 49 strcpy(item_string[i],old_item_string[i]);
7077 49 break;
7078 }
7079 1792 }
7080
7081
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7082 {
7083
4/4
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1778 times.
1792 if(i!=iBPotion && i!=iRPotion)
7084 1778 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7085
7086
43/43
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1477 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 7 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 7 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 7 times.
✓ Branch 16 taken 7 times.
✓ Branch 17 taken 7 times.
✓ Branch 18 taken 7 times.
✓ Branch 19 taken 7 times.
✓ Branch 20 taken 7 times.
✓ Branch 21 taken 7 times.
✓ Branch 22 taken 7 times.
✓ Branch 23 taken 7 times.
✓ Branch 24 taken 7 times.
✓ Branch 25 taken 7 times.
✓ Branch 26 taken 7 times.
✓ Branch 27 taken 7 times.
✓ Branch 28 taken 7 times.
✓ Branch 29 taken 7 times.
✓ Branch 30 taken 7 times.
✓ Branch 31 taken 7 times.
✓ Branch 32 taken 7 times.
✓ Branch 33 taken 7 times.
✓ Branch 34 taken 7 times.
✓ Branch 35 taken 7 times.
✓ Branch 36 taken 7 times.
✓ Branch 37 taken 7 times.
✓ Branch 38 taken 7 times.
✓ Branch 39 taken 7 times.
✓ Branch 40 taken 7 times.
✓ Branch 41 taken 7 times.
✓ Branch 42 taken 7 times.
1792 switch(i)
7087 {
7088 case iTriforce:
7089 7 tempitem.fam_type=1;
7090 7 break;
7091
7092 case iBigTri:
7093 7 tempitem.fam_type=0;
7094 7 break;
7095
7096 case iBombs:
7097 7 tempitem.fam_type=i_bomb;
7098 7 tempitem.power=4;
7099 7 tempitem.wpn=wBOMB;
7100 7 tempitem.wpn2=wBOOM;
7101 7 tempitem.misc1 = 50;
7102
7103
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 200; //qr_SLOWBOMBFUSES
7104
7105 7 break;
7106
7107 case iSBomb:
7108 7 tempitem.fam_type=i_sbomb;
7109 7 tempitem.power=16;
7110 7 tempitem.wpn=wSBOMB;
7111 7 tempitem.wpn2=wSBOOM;
7112 7 tempitem.misc1 = 50;
7113
7114
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(deprecated_rules,116)) tempitem.misc1 = 400; //qr_SLOWBOMBFUSES
7115
7116 7 break;
7117
7118 case iBook:
7119
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(deprecated_rules, 113))
7120 tempitem.wpn = wFIREMAGIC; //qr_FIREMAGICSPRITE
7121
7122 7 break;
7123
7124 case iSArrow:
7125 7 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7126 7 tempitem.power=4;
7127 7 tempitem.flags|=ITEM_GAMEDATA;
7128 7 tempitem.wpn=wSARROW;
7129 7 break;
7130
7131 case iGArrow:
7132 7 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7133 7 tempitem.power=8;
7134 7 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7135 7 tempitem.wpn=wGARROW;
7136 7 break;
7137
7138 case iBrang:
7139 7 tempitem.power=0;
7140 7 tempitem.wpn=wBRANG;
7141 7 tempitem.misc1=36;
7142 7 break;
7143
7144 case iMBrang:
7145 7 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7146 7 tempitem.power=0;
7147 7 tempitem.wpn=wMBRANG;
7148 7 break;
7149
7150 case iFBrang:
7151 7 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7152 7 tempitem.power=2;
7153 7 tempitem.wpn=wFBRANG;
7154 7 break;
7155
7156 case iBoots:
7157 7 tempitem.cost_amount[0] = get_bit(deprecated_rules,51) ? 1 : 0;
7158 7 tempitem.power=7;
7159 7 break;
7160
7161 case iWand:
7162 7 tempitem.cost_amount[0] = get_bit(deprecated_rules,49) ? 8 : 0;
7163 7 tempitem.power=2;
7164 7 tempitem.wpn=wWAND;
7165 7 tempitem.wpn3=wMAGIC;
7166 7 break;
7167
7168 case iBCandle:
7169 7 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7170 7 tempitem.power=1;
7171 7 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7172 7 tempitem.wpn3=wFIRE;
7173 7 break;
7174
7175 case iRCandle:
7176 7 tempitem.cost_amount[0] = get_bit(deprecated_rules,50) ? 4 : 0;
7177 7 tempitem.power=1;
7178 7 tempitem.wpn3=wFIRE;
7179 7 break;
7180
7181 case iSword:
7182 7 tempitem.power=1;
7183 7 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7184 7 tempitem.wpn=tempitem.wpn3=wSWORD;
7185 7 tempitem.wpn2=wSWORDSLASH;
7186 7 break;
7187
7188 case iWSword:
7189 7 tempitem.power=2;
7190 7 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7191 7 tempitem.wpn=tempitem.wpn3=wWSWORD;
7192 7 tempitem.wpn2=wWSWORDSLASH;
7193 7 break;
7194
7195 case iMSword:
7196 7 tempitem.power=4;
7197 7 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7198 7 tempitem.wpn=tempitem.wpn3=wMSWORD;
7199 7 tempitem.wpn2=wMSWORDSLASH;
7200 7 break;
7201
7202 case iXSword:
7203 7 tempitem.power=8;
7204 7 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7205 7 tempitem.wpn=tempitem.wpn3=wXSWORD;
7206 7 tempitem.wpn2=wXSWORDSLASH;
7207 7 break;
7208
7209 case iDivineProtection:
7210 7 tempitem.flags |= get_bit(deprecated_rules,76) ? ITEM_FLAG1 : 0;
7211 7 tempitem.flags |= get_bit(deprecated_rules,75) ? ITEM_FLAG2 : 0;
7212 7 tempitem.wpn=wDIVINEPROTECTION1A;
7213 7 tempitem.wpn2=wDIVINEPROTECTION1B;
7214 7 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7215 7 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7216 7 tempitem.wpn6=wDIVINEPROTECTION2A;
7217 7 tempitem.wpn7=wDIVINEPROTECTION2B;
7218 7 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7219 7 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7220 7 tempitem.wpn5 = iwDivineProtectionShieldFront;
7221 7 tempitem.wpn10 = iwDivineProtectionShieldBack;
7222 7 tempitem.misc1=512;
7223 7 tempitem.cost_amount[0]=64;
7224 7 break;
7225
7226 case iLens:
7227 7 tempitem.misc1=60;
7228 7 tempitem.flags |= get_bit(quest_rules,qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7229 7 tempitem.cost_amount[0] = get_bit(quest_rules,qr_ENABLEMAGIC) ? 2 : 1;
7230 7 break;
7231
7232 case iArrow:
7233 7 tempitem.power=2;
7234 7 tempitem.wpn=wARROW;
7235 7 break;
7236
7237 case iHoverBoots:
7238 7 tempitem.misc1=45;
7239 7 tempitem.wpn=iwHover;
7240 7 break;
7241
7242 case iDivineFire:
7243 7 tempitem.power=8;
7244 7 tempitem.wpn=wDIVINEFIRE1A;
7245 7 tempitem.wpn2=wDIVINEFIRE1B;
7246 7 tempitem.wpn3=wDIVINEFIRES1A;
7247 7 tempitem.wpn4=wDIVINEFIRES1B;
7248 7 tempitem.misc1 = 32;
7249 7 tempitem.misc2 = 200;
7250 7 tempitem.cost_amount[0]=32;
7251 7 break;
7252
7253 case iDivineEscape:
7254 7 tempitem.cost_amount[0]=32;
7255 7 break;
7256
7257 case iHookshot:
7258 7 tempitem.power=0;
7259 7 tempitem.flags&=~ITEM_FLAG1;
7260 7 tempitem.wpn=wHSHEAD;
7261 7 tempitem.wpn2=wHSCHAIN_H;
7262 7 tempitem.wpn4=wHSHANDLE;
7263 7 tempitem.wpn3=wHSCHAIN_V;
7264 7 tempitem.misc1=50;
7265 7 tempitem.misc2=100;
7266 7 break;
7267
7268 case iLongshot:
7269 7 tempitem.power=0;
7270 7 tempitem.flags&=~ITEM_FLAG1;
7271 7 tempitem.wpn=wLSHEAD;
7272 7 tempitem.wpn2=wLSCHAIN_H;
7273 7 tempitem.wpn4=wLSHANDLE;
7274 7 tempitem.wpn3=wLSCHAIN_V;
7275 7 tempitem.misc1=99;
7276 7 tempitem.misc2=100;
7277 7 break;
7278
7279 case iHammer:
7280 7 tempitem.power=4;
7281 7 tempitem.wpn=wHAMMER;
7282 7 tempitem.wpn2=iwHammerSmack;
7283 7 break;
7284
7285 case iCByrna:
7286 7 tempitem.power=1;
7287 7 tempitem.wpn=wCBYRNA;
7288 7 tempitem.wpn2=wCBYRNASLASH;
7289 7 tempitem.wpn3=wCBYRNAORB;
7290 7 tempitem.misc1=4;
7291 7 tempitem.misc2=16;
7292 7 tempitem.misc3=1;
7293 7 tempitem.cost_amount[0]=1;
7294 7 break;
7295
7296 case iWhistle:
7297 7 tempitem.wpn=wWIND;
7298 7 tempitem.misc1=3;
7299 7 tempitem.flags|=ITEM_FLAG1;
7300 7 break;
7301
7302 case iBRing:
7303 7 tempitem.power=2;
7304 7 tempitem.misc1=spBLUE;
7305 7 break;
7306
7307 case iRRing:
7308 7 tempitem.power=4;
7309 7 tempitem.misc1=spRED;
7310 7 break;
7311
7312 case iGRing:
7313 7 tempitem.power=8;
7314 7 tempitem.misc1=spGOLD;
7315 7 break;
7316
7317 case iSpinScroll:
7318 7 tempitem.power = 2;
7319 7 tempitem.misc1 = 1;
7320 7 break;
7321
7322 case iL2SpinScroll:
7323 7 tempitem.family=itype_spinscroll2;
7324 7 tempitem.fam_type=1;
7325 7 tempitem.cost_amount[0]=8;
7326 7 tempitem.power=2;
7327 7 tempitem.misc1 = 20;
7328 7 break;
7329
7330 case iQuakeScroll:
7331 7 tempitem.misc1=0x10;
7332 7 tempitem.misc2=64;
7333 7 break;
7334
7335 case iL2QuakeScroll:
7336 7 tempitem.family=itype_quakescroll2;
7337 7 tempitem.fam_type=1;
7338 7 tempitem.power = 2;
7339 7 tempitem.misc1=0x20;
7340 7 tempitem.misc2=192;
7341 7 tempitem.cost_amount[0]=8;
7342 7 break;
7343
7344 case iChargeRing:
7345 7 tempitem.misc1=64;
7346 7 tempitem.misc2=128;
7347 7 break;
7348
7349 case iL2ChargeRing:
7350 7 tempitem.misc1=32;
7351 7 tempitem.misc2=64;
7352 7 break;
7353
7354 case iOldGlove:
7355 7 tempitem.flags |= ITEM_FLAG1;
7356
7357 //fallthrough
7358 case iBombBagL4:
7359 case iWalletL3:
7360 case iQuiverL4:
7361 case iBracelet:
7362 35 tempitem.power = 1;
7363 35 break;
7364
7365 case iL2Bracelet:
7366 7 tempitem.power = 2;
7367 7 break;
7368
7369 case iMKey:
7370 7 tempitem.power=0xFF;
7371 7 tempitem.flags |= ITEM_FLAG1;
7372 7 break;
7373 }
7374 1792 }
7375
7376
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 7)
7377 {
7378
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 1764 times.
1792 switch(i)
7379 {
7380 case iStoneAgony:
7381 case iStompBoots:
7382 case iPerilRing:
7383 case iWhimsicalRing:
7384 {
7385 28 reset_itembuf(&tempitem, i);
7386 28 strcpy(item_string[i],old_item_string[i]);
7387 28 break;
7388 }
7389 }
7390 1792 }
7391
7392
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 8) // May 2007: Some corrections.
7393 {
7394
7/7
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1736 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 7 times.
1792 switch(i)
7395 {
7396 case iMShield:
7397 7 tempitem.misc1|=shFLAME;
7398 7 tempitem.misc2|=shFIREBALL|shMAGIC;
7399
7400
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(quest_rules, qr_SWORDMIRROR))
7401 {
7402 tempitem.misc2 |= shSWORD;
7403 }
7404
7405 // fallthrough
7406 case iShield:
7407 14 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7408
7409 // fallthrough
7410 case iSShield:
7411 21 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7412
7413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7414 {
7415 tempitem.misc2 |= shROCK;
7416 }
7417
7418 21 break;
7419
7420 case iWhispRing:
7421 7 tempitem.power=1;
7422 7 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7423 7 tempitem.misc1 = 3;
7424 7 break;
7425
7426 case iL2WhispRing:
7427 7 tempitem.power=0;
7428 7 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7429 7 tempitem.misc1 = 3;
7430 7 break;
7431
7432 case iL2Ladder:
7433 case iBow:
7434 case iCByrna:
7435 21 tempitem.power = 1;
7436 21 break;
7437 }
7438 1792 }
7439
7440
4/4
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 24832 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 7 times.
26624 if(s_version < 9 && i==iClock)
7441 {
7442 7 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7443 7 }
7444
7445 //add the misc flag for bomb
7446
4/4
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 24832 times.
✓ Branch 2 taken 1785 times.
✓ Branch 3 taken 7 times.
26624 if(s_version < 10 && tempitem.family == itype_bomb)
7447 {
7448 7 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_bit(quest_rules, qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7449 7 }
7450
7451
4/4
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 24832 times.
✓ Branch 2 taken 1778 times.
✓ Branch 3 taken 14 times.
26624 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7452 {
7453 14 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7454 14 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7455 14 }
7456
7457
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 12) // June 2007: More Misc. attributes.
7458 {
7459
5/5
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1757 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
1792 switch(i)
7460 {
7461 case iFBrang:
7462 7 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7463
7464 //fallthrough
7465 case iMBrang:
7466 14 tempitem.misc3 |= shSWORD|shMAGIC;
7467
7468 //fallthrough
7469 case iHookshot:
7470 case iLongshot:
7471 //fallthrough
7472 28 tempitem.misc3 |= shFIREBALL;
7473
7474 case iBrang:
7475 35 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7476 35 break;
7477 }
7478
7479
16/16
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 884 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 21 times.
✓ Branch 7 taken 14 times.
✓ Branch 8 taken 21 times.
✓ Branch 9 taken 21 times.
✓ Branch 10 taken 733 times.
✓ Branch 11 taken 7 times.
✓ Branch 12 taken 7 times.
✓ Branch 13 taken 7 times.
✓ Branch 14 taken 7 times.
✓ Branch 15 taken 7 times.
1792 switch(tempitem.family)
7480 {
7481 case itype_hoverboots:
7482 7 tempitem.usesound = WAV_ZN1HOVER;
7483 7 break;
7484
7485 case itype_wand:
7486 7 tempitem.usesound = WAV_WAND;
7487 7 break;
7488
7489 case itype_book:
7490 7 tempitem.usesound = WAV_FIRE;
7491 7 break;
7492
7493 case itype_arrow:
7494 21 tempitem.usesound = WAV_ARROW;
7495 21 break;
7496
7497 case itype_hookshot:
7498 14 tempitem.usesound = WAV_HOOKSHOT;
7499 14 break;
7500
7501 case itype_brang:
7502 21 tempitem.usesound = WAV_BRANG;
7503 21 break;
7504
7505 case itype_shield:
7506 21 tempitem.usesound = WAV_CHINK;
7507 21 break;
7508
7509 case itype_sword:
7510 733 tempitem.usesound = WAV_SWORD;
7511 733 break;
7512
7513 case itype_whistle:
7514 7 tempitem.usesound = WAV_WHISTLE;
7515 7 break;
7516
7517 case itype_hammer:
7518 7 tempitem.usesound = WAV_HAMMER;
7519 7 break;
7520
7521 case itype_divinefire:
7522 7 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7523 7 break;
7524
7525 case itype_divineescape:
7526 7 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7527 7 break;
7528
7529 case itype_divineprotection:
7530 7 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7531 7 break;
7532
7533 case itype_bomb:
7534 case itype_sbomb:
7535 case itype_quakescroll:
7536 case itype_quakescroll2:
7537 28 tempitem.usesound = WAV_BOMB;
7538 28 break;
7539
7540 case itype_spinscroll:
7541 case itype_spinscroll2:
7542 14 tempitem.usesound = WAV_ZN1SPINATTACK;
7543 14 break;
7544 }
7545 1792 }
7546
7547
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 13) // July 2007
7548 {
7549
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1785 times.
1792 if(tempitem.family == itype_whistle)
7550 {
7551 7 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7552 7 tempitem.power = 1;
7553 7 tempitem.flags|=ITEM_FLAG1;
7554 7 }
7555
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1778 times.
1785 else if(tempitem.family == itype_wand)
7556 7 tempitem.flags|=ITEM_FLAG1;
7557
2/2
✓ Branch 0 taken 1771 times.
✓ Branch 1 taken 7 times.
1778 else if(tempitem.family == itype_book)
7558 {
7559 7 tempitem.flags|=ITEM_FLAG1;
7560 7 tempitem.power = 2;
7561 7 }
7562 1792 }
7563
7564
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 14) // August 2007
7565 {
7566
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1778 times.
1792 if(tempitem.family == itype_fairy)
7567 {
7568 14 tempitem.usesound = WAV_SCALE;
7569
7570
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 if(tempitem.fam_type)
7571 14 tempitem.misc3=50;
7572 14 }
7573
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 14 times.
1778 else if(tempitem.family == itype_potion)
7574 {
7575 14 tempitem.flags |= ITEM_GAINOLD;
7576 14 }
7577 1792 }
7578
7579
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 17) // November 2007
7580 {
7581
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 1778 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
1792 if(tempitem.family == itype_candle && !tempitem.wpn3)
7582 {
7583 tempitem.wpn3 = wFIRE;
7584 }
7585
4/4
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 1771 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 7 times.
1792 else if(tempitem.family == itype_arrow && tempitem.power>4)
7586 {
7587 7 tempitem.flags|=ITEM_FLAG1;
7588 7 }
7589 1792 }
7590
7591
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 18) // New Year's Eve 2007
7592 {
7593
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1785 times.
1792 if(tempitem.family == itype_whistle)
7594 7 tempitem.misc2 = 8; // Use the Whistle warp ring
7595
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1778 times.
1785 else if(tempitem.family == itype_bait)
7596 7 tempitem.misc1 = 768; // Frames until it goes
7597
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 14 times.
1778 else if(tempitem.family == itype_triforcepiece)
7598 {
7599
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
14 if(tempitem.flags & ITEM_GAMEDATA)
7600 {
7601 7 tempitem.misc2 = 1; // Cutscene 1
7602 7 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7603 7 }
7604 14 }
7605 1792 }
7606
7607
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 19) // January 2008
7608 {
7609
2/2
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 7 times.
1792 if(tempitem.family == itype_divineprotection)
7610 {
7611 7 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7612 7 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7613 7 }
7614 1792 }
7615
7616
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 20) // October 2008
7617 {
7618
2/2
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 7 times.
1792 if(tempitem.family == itype_divineprotection)
7619 {
7620 7 tempitem.wpn6=wDIVINEPROTECTION2A;
7621 7 tempitem.wpn7=wDIVINEPROTECTION2B;
7622 7 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7623 7 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7624 7 tempitem.wpn5 = iwDivineProtectionShieldFront;
7625 7 tempitem.wpn10 = iwDivineProtectionShieldBack;
7626 7 }
7627 1792 }
7628
7629
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 21) // November 2008
7630 {
7631
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(tempitem.flags & 0x0100) // ITEM_SLASH
7632 {
7633 tempitem.flags &= ~0x0100;
7634
7635 if(tempitem.family == itype_sword ||
7636 tempitem.family == itype_wand ||
7637 tempitem.family == itype_candle ||
7638 tempitem.family == itype_cbyrna)
7639 {
7640 tempitem.flags |= ITEM_FLAG4;
7641 }
7642 }
7643 1792 }
7644
7645
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 22) // September 2009
7646 {
7647
4/4
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 1778 times.
1792 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7648 {
7649 14 tempitem.misc3 = tempitem.power/2;
7650 14 }
7651 1792 }
7652
7653
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 23) // March 2011
7654 {
7655
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1785 times.
1792 if(tempitem.family == itype_divinefire)
7656 7 tempitem.wpn5 = wFIRE;
7657
2/2
✓ Branch 0 taken 1778 times.
✓ Branch 1 taken 7 times.
1785 else if(tempitem.family == itype_book)
7658 7 tempitem.wpn2 = wFIRE;
7659 1792 }
7660
7661 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7662 // whether it was or not, and a lot of existing quests depended on the
7663 // incorrect behavior.
7664
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 1792 times.
26624 if(s_version < 25) // January 2012
7665 {
7666
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 28 times.
1792 if(tempitem.family == itype_bombbag)
7667 28 tempitem.flags |= 16;
7668
7669
2/2
✓ Branch 0 taken 1785 times.
✓ Branch 1 taken 7 times.
1792 if(tempitem.family == itype_divinefire)
7670 7 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7671 1792 }
7672
7673
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7674 {
7675
60/60
✓ Branch 0 taken 2037 times.
✓ Branch 1 taken 867 times.
✓ Branch 2 taken 243 times.
✓ Branch 3 taken 1014 times.
✓ Branch 4 taken 2383 times.
✓ Branch 5 taken 6796 times.
✓ Branch 6 taken 243 times.
✓ Branch 7 taken 241 times.
✓ Branch 8 taken 200 times.
✓ Branch 9 taken 127 times.
✓ Branch 10 taken 81 times.
✓ Branch 11 taken 162 times.
✓ Branch 12 taken 161 times.
✓ Branch 13 taken 96 times.
✓ Branch 14 taken 243 times.
✓ Branch 15 taken 243 times.
✓ Branch 16 taken 160 times.
✓ Branch 17 taken 243 times.
✓ Branch 18 taken 162 times.
✓ Branch 19 taken 81 times.
✓ Branch 20 taken 162 times.
✓ Branch 21 taken 96 times.
✓ Branch 22 taken 81 times.
✓ Branch 23 taken 243 times.
✓ Branch 24 taken 81 times.
✓ Branch 25 taken 81 times.
✓ Branch 26 taken 162 times.
✓ Branch 27 taken 81 times.
✓ Branch 28 taken 81 times.
✓ Branch 29 taken 81 times.
✓ Branch 30 taken 81 times.
✓ Branch 31 taken 81 times.
✓ Branch 32 taken 96 times.
✓ Branch 33 taken 81 times.
✓ Branch 34 taken 81 times.
✓ Branch 35 taken 81 times.
✓ Branch 36 taken 81 times.
✓ Branch 37 taken 162 times.
✓ Branch 38 taken 324 times.
✓ Branch 39 taken 81 times.
✓ Branch 40 taken 81 times.
✓ Branch 41 taken 144 times.
✓ Branch 42 taken 324 times.
✓ Branch 43 taken 81 times.
✓ Branch 44 taken 81 times.
✓ Branch 45 taken 81 times.
✓ Branch 46 taken 81 times.
✓ Branch 47 taken 81 times.
✓ Branch 48 taken 162 times.
✓ Branch 49 taken 162 times.
✓ Branch 50 taken 81 times.
✓ Branch 51 taken 243 times.
✓ Branch 52 taken 243 times.
✓ Branch 53 taken 324 times.
✓ Branch 54 taken 81 times.
✓ Branch 55 taken 81 times.
✓ Branch 56 taken 81 times.
✓ Branch 57 taken 81 times.
✓ Branch 58 taken 81 times.
✓ Branch 59 taken 81 times.
20736 switch(tempitem.family)
7676 {
7677 case itype_sword:
7678 {
7679 6796 tempitem.flags &= ~(ITEM_FLAG5);
7680 6796 tempitem.misc3 = 0;
7681 6796 tempitem.misc4 = 0;
7682 6796 tempitem.misc5 = 0;
7683 6796 tempitem.misc6 = 0;
7684 6796 tempitem.misc7 = 0;
7685 6796 tempitem.misc8 = 0;
7686 6796 tempitem.misc9 = 0;
7687 6796 tempitem.misc10 = 0;
7688 6796 tempitem.wpn4 = 0;
7689 6796 tempitem.wpn5 = 0;
7690 6796 tempitem.wpn6 = 0;
7691 6796 tempitem.wpn7 = 0;
7692 6796 tempitem.wpn8 = 0;
7693 6796 tempitem.wpn9 = 0;
7694 6796 tempitem.wpn10 = 0;
7695 6796 break;
7696 }
7697 case itype_brang:
7698 {
7699 243 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7700 243 tempitem.misc2 = 0;
7701 243 tempitem.misc5 = 0;
7702 243 tempitem.misc6 = 0;
7703 243 tempitem.misc7 = 0;
7704 243 tempitem.misc8 = 0;
7705 243 tempitem.misc9 = 0;
7706 243 tempitem.misc10 = 0;
7707 243 tempitem.wpn4 = 0;
7708 243 tempitem.wpn5 = 0;
7709 243 tempitem.wpn6 = 0;
7710 243 tempitem.wpn7 = 0;
7711 243 tempitem.wpn8 = 0;
7712 243 tempitem.wpn9 = 0;
7713 243 tempitem.wpn10 = 0;
7714 243 break;
7715 }
7716 case itype_arrow:
7717 {
7718 241 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7719 241 tempitem.misc2 = 0;
7720 241 tempitem.misc3 = 0;
7721 241 tempitem.misc4 = 0;
7722 241 tempitem.misc5 = 0;
7723 241 tempitem.misc6 = 0;
7724 241 tempitem.misc7 = 0;
7725 241 tempitem.misc8 = 0;
7726 241 tempitem.misc9 = 0;
7727 241 tempitem.misc10 = 0;
7728 241 tempitem.wpn4 = 0;
7729 241 tempitem.wpn5 = 0;
7730 241 tempitem.wpn6 = 0;
7731 241 tempitem.wpn7 = 0;
7732 241 tempitem.wpn8 = 0;
7733 241 tempitem.wpn9 = 0;
7734 241 tempitem.wpn10 = 0;
7735 241 break;
7736 }
7737 case itype_candle:
7738 {
7739 200 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7740 200 tempitem.misc1 = 0;
7741 200 tempitem.misc2 = 0;
7742 200 tempitem.misc3 = 0;
7743 200 tempitem.misc4 = 0;
7744 200 tempitem.misc5 = 0;
7745 200 tempitem.misc6 = 0;
7746 200 tempitem.misc7 = 0;
7747 200 tempitem.misc8 = 0;
7748 200 tempitem.misc9 = 0;
7749 200 tempitem.misc10 = 0;
7750 200 tempitem.wpn4 = 0;
7751 200 tempitem.wpn5 = 0;
7752 200 tempitem.wpn6 = 0;
7753 200 tempitem.wpn7 = 0;
7754 200 tempitem.wpn8 = 0;
7755 200 tempitem.wpn9 = 0;
7756 200 tempitem.wpn10 = 0;
7757 200 break;
7758 }
7759 case itype_whistle:
7760 {
7761 127 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7762 127 tempitem.misc3 = 0;
7763 127 tempitem.misc4 = 0;
7764 127 tempitem.misc5 = 0;
7765 127 tempitem.misc6 = 0;
7766 127 tempitem.misc7 = 0;
7767 127 tempitem.misc8 = 0;
7768 127 tempitem.misc9 = 0;
7769 127 tempitem.misc10 = 0;
7770 127 tempitem.wpn2 = 0;
7771 127 tempitem.wpn3 = 0;
7772 127 tempitem.wpn4 = 0;
7773 127 tempitem.wpn5 = 0;
7774 127 tempitem.wpn6 = 0;
7775 127 tempitem.wpn7 = 0;
7776 127 tempitem.wpn8 = 0;
7777 127 tempitem.wpn9 = 0;
7778 127 tempitem.wpn10 = 0;
7779 127 break;
7780 }
7781 case itype_bait:
7782 {
7783 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7784 81 tempitem.misc2 = 0;
7785 81 tempitem.misc3 = 0;
7786 81 tempitem.misc4 = 0;
7787 81 tempitem.misc5 = 0;
7788 81 tempitem.misc6 = 0;
7789 81 tempitem.misc7 = 0;
7790 81 tempitem.misc8 = 0;
7791 81 tempitem.misc9 = 0;
7792 81 tempitem.misc10 = 0;
7793 81 tempitem.wpn2 = 0;
7794 81 tempitem.wpn3 = 0;
7795 81 tempitem.wpn4 = 0;
7796 81 tempitem.wpn5 = 0;
7797 81 tempitem.wpn6 = 0;
7798 81 tempitem.wpn7 = 0;
7799 81 tempitem.wpn8 = 0;
7800 81 tempitem.wpn9 = 0;
7801 81 tempitem.wpn10 = 0;
7802 81 break;
7803 }
7804 case itype_letter:
7805 {
7806 162 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7807 162 tempitem.misc1 = 0;
7808 162 tempitem.misc2 = 0;
7809 162 tempitem.misc3 = 0;
7810 162 tempitem.misc4 = 0;
7811 162 tempitem.misc5 = 0;
7812 162 tempitem.misc6 = 0;
7813 162 tempitem.misc7 = 0;
7814 162 tempitem.misc8 = 0;
7815 162 tempitem.misc9 = 0;
7816 162 tempitem.misc10 = 0;
7817 162 tempitem.wpn = 0;
7818 162 tempitem.wpn2 = 0;
7819 162 tempitem.wpn3 = 0;
7820 162 tempitem.wpn4 = 0;
7821 162 tempitem.wpn5 = 0;
7822 162 tempitem.wpn6 = 0;
7823 162 tempitem.wpn7 = 0;
7824 162 tempitem.wpn8 = 0;
7825 162 tempitem.wpn9 = 0;
7826 162 tempitem.wpn10 = 0;
7827 162 break;
7828 }
7829 case itype_potion:
7830 {
7831 161 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7832 161 tempitem.misc3 = 0;
7833 161 tempitem.misc4 = 0;
7834 161 tempitem.misc5 = 0;
7835 161 tempitem.misc6 = 0;
7836 161 tempitem.misc7 = 0;
7837 161 tempitem.misc8 = 0;
7838 161 tempitem.misc9 = 0;
7839 161 tempitem.misc10 = 0;
7840 161 tempitem.wpn = 0;
7841 161 tempitem.wpn2 = 0;
7842 161 tempitem.wpn3 = 0;
7843 161 tempitem.wpn4 = 0;
7844 161 tempitem.wpn5 = 0;
7845 161 tempitem.wpn6 = 0;
7846 161 tempitem.wpn7 = 0;
7847 161 tempitem.wpn8 = 0;
7848 161 tempitem.wpn9 = 0;
7849 161 tempitem.wpn10 = 0;
7850 161 break;
7851 }
7852 case itype_wand:
7853 {
7854 96 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
7855 96 tempitem.misc1 = 0;
7856 96 tempitem.misc2 = 0;
7857 96 tempitem.misc3 = 0;
7858 96 tempitem.misc4 = 0;
7859 96 tempitem.misc5 = 0;
7860 96 tempitem.misc6 = 0;
7861 96 tempitem.misc7 = 0;
7862 96 tempitem.misc8 = 0;
7863 96 tempitem.misc9 = 0;
7864 96 tempitem.misc10 = 0;
7865 96 tempitem.wpn4 = 0;
7866 96 tempitem.wpn5 = 0;
7867 96 tempitem.wpn6 = 0;
7868 96 tempitem.wpn7 = 0;
7869 96 tempitem.wpn8 = 0;
7870 96 tempitem.wpn9 = 0;
7871 96 tempitem.wpn10 = 0;
7872 96 break;
7873 }
7874 case itype_ring:
7875 {
7876 243 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7877 243 tempitem.misc2 = 0;
7878 243 tempitem.misc3 = 0;
7879 243 tempitem.misc4 = 0;
7880 243 tempitem.misc5 = 0;
7881 243 tempitem.misc6 = 0;
7882 243 tempitem.misc7 = 0;
7883 243 tempitem.misc8 = 0;
7884 243 tempitem.misc9 = 0;
7885 243 tempitem.misc10 = 0;
7886 243 tempitem.wpn = 0;
7887 243 tempitem.wpn2 = 0;
7888 243 tempitem.wpn3 = 0;
7889 243 tempitem.wpn4 = 0;
7890 243 tempitem.wpn5 = 0;
7891 243 tempitem.wpn6 = 0;
7892 243 tempitem.wpn7 = 0;
7893 243 tempitem.wpn8 = 0;
7894 243 tempitem.wpn9 = 0;
7895 243 tempitem.wpn10 = 0;
7896 243 break;
7897 }
7898 case itype_wallet:
7899 {
7900 243 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7901 243 tempitem.misc3 = 0;
7902 243 tempitem.misc4 = 0;
7903 243 tempitem.misc5 = 0;
7904 243 tempitem.misc6 = 0;
7905 243 tempitem.misc7 = 0;
7906 243 tempitem.misc8 = 0;
7907 243 tempitem.misc9 = 0;
7908 243 tempitem.misc10 = 0;
7909 243 tempitem.wpn = 0;
7910 243 tempitem.wpn2 = 0;
7911 243 tempitem.wpn3 = 0;
7912 243 tempitem.wpn4 = 0;
7913 243 tempitem.wpn5 = 0;
7914 243 tempitem.wpn6 = 0;
7915 243 tempitem.wpn7 = 0;
7916 243 tempitem.wpn8 = 0;
7917 243 tempitem.wpn9 = 0;
7918 243 tempitem.wpn10 = 0;
7919 243 break;
7920 }
7921 case itype_amulet:
7922 {
7923 160 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7924 160 tempitem.misc1 = 0;
7925 160 tempitem.misc2 = 0;
7926 160 tempitem.misc3 = 0;
7927 160 tempitem.misc4 = 0;
7928 160 tempitem.misc5 = 0;
7929 160 tempitem.misc6 = 0;
7930 160 tempitem.misc7 = 0;
7931 160 tempitem.misc8 = 0;
7932 160 tempitem.misc9 = 0;
7933 160 tempitem.misc10 = 0;
7934 160 tempitem.wpn = 0;
7935 160 tempitem.wpn2 = 0;
7936 160 tempitem.wpn3 = 0;
7937 160 tempitem.wpn4 = 0;
7938 160 tempitem.wpn5 = 0;
7939 160 tempitem.wpn6 = 0;
7940 160 tempitem.wpn7 = 0;
7941 160 tempitem.wpn8 = 0;
7942 160 tempitem.wpn9 = 0;
7943 160 tempitem.wpn10 = 0;
7944 160 break;
7945 }
7946 case itype_shield:
7947 {
7948 243 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7949 243 tempitem.misc3 = 0;
7950 243 tempitem.misc4 = 0;
7951 243 tempitem.misc5 = 0;
7952 243 tempitem.misc6 = 0;
7953 243 tempitem.misc7 = 0;
7954 243 tempitem.misc8 = 0;
7955 243 tempitem.misc9 = 0;
7956 243 tempitem.misc10 = 0;
7957 243 tempitem.wpn = 0;
7958 243 tempitem.wpn2 = 0;
7959 243 tempitem.wpn3 = 0;
7960 243 tempitem.wpn4 = 0;
7961 243 tempitem.wpn5 = 0;
7962 243 tempitem.wpn6 = 0;
7963 243 tempitem.wpn7 = 0;
7964 243 tempitem.wpn8 = 0;
7965 243 tempitem.wpn9 = 0;
7966 243 tempitem.wpn10 = 0;
7967 243 break;
7968 }
7969 case itype_bow:
7970 {
7971 162 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7972 162 tempitem.misc1 = 0;
7973 162 tempitem.misc2 = 0;
7974 162 tempitem.misc3 = 0;
7975 162 tempitem.misc4 = 0;
7976 162 tempitem.misc5 = 0;
7977 162 tempitem.misc6 = 0;
7978 162 tempitem.misc7 = 0;
7979 162 tempitem.misc8 = 0;
7980 162 tempitem.misc9 = 0;
7981 162 tempitem.misc10 = 0;
7982 162 tempitem.wpn = 0;
7983 162 tempitem.wpn2 = 0;
7984 162 tempitem.wpn3 = 0;
7985 162 tempitem.wpn4 = 0;
7986 162 tempitem.wpn5 = 0;
7987 162 tempitem.wpn6 = 0;
7988 162 tempitem.wpn7 = 0;
7989 162 tempitem.wpn8 = 0;
7990 162 tempitem.wpn9 = 0;
7991 162 tempitem.wpn10 = 0;
7992 162 break;
7993 }
7994 case itype_raft:
7995 {
7996 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7997 81 tempitem.misc1 = 0;
7998 81 tempitem.misc2 = 0;
7999 81 tempitem.misc3 = 0;
8000 81 tempitem.misc4 = 0;
8001 81 tempitem.misc5 = 0;
8002 81 tempitem.misc6 = 0;
8003 81 tempitem.misc7 = 0;
8004 81 tempitem.misc8 = 0;
8005 81 tempitem.misc9 = 0;
8006 81 tempitem.misc10 = 0;
8007 81 tempitem.wpn = 0;
8008 81 tempitem.wpn2 = 0;
8009 81 tempitem.wpn3 = 0;
8010 81 tempitem.wpn4 = 0;
8011 81 tempitem.wpn5 = 0;
8012 81 tempitem.wpn6 = 0;
8013 81 tempitem.wpn7 = 0;
8014 81 tempitem.wpn8 = 0;
8015 81 tempitem.wpn9 = 0;
8016 81 tempitem.wpn10 = 0;
8017 81 break;
8018 }
8019 case itype_ladder:
8020 {
8021 162 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8022 162 tempitem.misc1 = 0;
8023 162 tempitem.misc2 = 0;
8024 162 tempitem.misc3 = 0;
8025 162 tempitem.misc4 = 0;
8026 162 tempitem.misc5 = 0;
8027 162 tempitem.misc6 = 0;
8028 162 tempitem.misc7 = 0;
8029 162 tempitem.misc8 = 0;
8030 162 tempitem.misc9 = 0;
8031 162 tempitem.misc10 = 0;
8032 162 tempitem.wpn = 0;
8033 162 tempitem.wpn2 = 0;
8034 162 tempitem.wpn3 = 0;
8035 162 tempitem.wpn4 = 0;
8036 162 tempitem.wpn5 = 0;
8037 162 tempitem.wpn6 = 0;
8038 162 tempitem.wpn7 = 0;
8039 162 tempitem.wpn8 = 0;
8040 162 tempitem.wpn9 = 0;
8041 162 tempitem.wpn10 = 0;
8042 162 break;
8043 }
8044 case itype_book:
8045 {
8046 96 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8047 96 tempitem.misc1 = 0;
8048 96 tempitem.misc2 = 0;
8049 96 tempitem.misc3 = 0;
8050 96 tempitem.misc4 = 0;
8051 96 tempitem.misc5 = 0;
8052 96 tempitem.misc6 = 0;
8053 96 tempitem.misc7 = 0;
8054 96 tempitem.misc8 = 0;
8055 96 tempitem.misc9 = 0;
8056 96 tempitem.misc10 = 0;
8057 96 tempitem.wpn3 = 0;
8058 96 tempitem.wpn4 = 0;
8059 96 tempitem.wpn5 = 0;
8060 96 tempitem.wpn6 = 0;
8061 96 tempitem.wpn7 = 0;
8062 96 tempitem.wpn8 = 0;
8063 96 tempitem.wpn9 = 0;
8064 96 tempitem.wpn10 = 0;
8065 96 break;
8066 }
8067 case itype_magickey:
8068 {
8069 81 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8070 81 tempitem.misc1 = 0;
8071 81 tempitem.misc2 = 0;
8072 81 tempitem.misc3 = 0;
8073 81 tempitem.misc4 = 0;
8074 81 tempitem.misc5 = 0;
8075 81 tempitem.misc6 = 0;
8076 81 tempitem.misc7 = 0;
8077 81 tempitem.misc8 = 0;
8078 81 tempitem.misc9 = 0;
8079 81 tempitem.misc10 = 0;
8080 81 tempitem.wpn = 0;
8081 81 tempitem.wpn2 = 0;
8082 81 tempitem.wpn3 = 0;
8083 81 tempitem.wpn4 = 0;
8084 81 tempitem.wpn5 = 0;
8085 81 tempitem.wpn6 = 0;
8086 81 tempitem.wpn7 = 0;
8087 81 tempitem.wpn8 = 0;
8088 81 tempitem.wpn9 = 0;
8089 81 tempitem.wpn10 = 0;
8090 81 break;
8091 }
8092 case itype_bracelet:
8093 {
8094 243 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8095 243 tempitem.misc1 = 0;
8096 243 tempitem.misc2 = 0;
8097 243 tempitem.misc3 = 0;
8098 243 tempitem.misc4 = 0;
8099 243 tempitem.misc5 = 0;
8100 243 tempitem.misc6 = 0;
8101 243 tempitem.misc7 = 0;
8102 243 tempitem.misc8 = 0;
8103 243 tempitem.misc9 = 0;
8104 243 tempitem.misc10 = 0;
8105 243 tempitem.wpn = 0;
8106 243 tempitem.wpn2 = 0;
8107 243 tempitem.wpn3 = 0;
8108 243 tempitem.wpn4 = 0;
8109 243 tempitem.wpn5 = 0;
8110 243 tempitem.wpn6 = 0;
8111 243 tempitem.wpn7 = 0;
8112 243 tempitem.wpn8 = 0;
8113 243 tempitem.wpn9 = 0;
8114 243 tempitem.wpn10 = 0;
8115 243 break;
8116 }
8117 case itype_flippers:
8118 {
8119 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8120 81 tempitem.misc1 = 0;
8121 81 tempitem.misc2 = 0;
8122 81 tempitem.misc3 = 0;
8123 81 tempitem.misc4 = 0;
8124 81 tempitem.misc5 = 0;
8125 81 tempitem.misc6 = 0;
8126 81 tempitem.misc7 = 0;
8127 81 tempitem.misc8 = 0;
8128 81 tempitem.misc9 = 0;
8129 81 tempitem.misc10 = 0;
8130 81 tempitem.wpn = 0;
8131 81 tempitem.wpn2 = 0;
8132 81 tempitem.wpn3 = 0;
8133 81 tempitem.wpn4 = 0;
8134 81 tempitem.wpn5 = 0;
8135 81 tempitem.wpn6 = 0;
8136 81 tempitem.wpn7 = 0;
8137 81 tempitem.wpn8 = 0;
8138 81 tempitem.wpn9 = 0;
8139 81 tempitem.wpn10 = 0;
8140 81 break;
8141 }
8142 case itype_boots:
8143 {
8144 81 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8145 81 tempitem.misc1 = 0;
8146 81 tempitem.misc2 = 0;
8147 81 tempitem.misc3 = 0;
8148 81 tempitem.misc4 = 0;
8149 81 tempitem.misc5 = 0;
8150 81 tempitem.misc6 = 0;
8151 81 tempitem.misc7 = 0;
8152 81 tempitem.misc8 = 0;
8153 81 tempitem.misc9 = 0;
8154 81 tempitem.misc10 = 0;
8155 81 tempitem.wpn = 0;
8156 81 tempitem.wpn2 = 0;
8157 81 tempitem.wpn3 = 0;
8158 81 tempitem.wpn4 = 0;
8159 81 tempitem.wpn5 = 0;
8160 81 tempitem.wpn6 = 0;
8161 81 tempitem.wpn7 = 0;
8162 81 tempitem.wpn8 = 0;
8163 81 tempitem.wpn9 = 0;
8164 81 tempitem.wpn10 = 0;
8165 81 break;
8166 }
8167 case itype_hookshot:
8168 {
8169 162 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8170 162 tempitem.misc5 = 0;
8171 162 tempitem.misc6 = 0;
8172 162 tempitem.misc7 = 0;
8173 162 tempitem.misc8 = 0;
8174 162 tempitem.misc9 = 0;
8175 162 tempitem.misc10 = 0;
8176 162 tempitem.wpn5 = 0;
8177 162 tempitem.wpn6 = 0;
8178 162 tempitem.wpn7 = 0;
8179 162 tempitem.wpn8 = 0;
8180 162 tempitem.wpn9 = 0;
8181 162 tempitem.wpn10 = 0;
8182 162 break;
8183 }
8184 case itype_lens:
8185 {
8186 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8187 81 tempitem.misc2 = 0;
8188 81 tempitem.misc3 = 0;
8189 81 tempitem.misc4 = 0;
8190 81 tempitem.misc5 = 0;
8191 81 tempitem.misc6 = 0;
8192 81 tempitem.misc7 = 0;
8193 81 tempitem.misc8 = 0;
8194 81 tempitem.misc9 = 0;
8195 81 tempitem.misc10 = 0;
8196 81 tempitem.wpn = 0;
8197 81 tempitem.wpn2 = 0;
8198 81 tempitem.wpn3 = 0;
8199 81 tempitem.wpn4 = 0;
8200 81 tempitem.wpn5 = 0;
8201 81 tempitem.wpn6 = 0;
8202 81 tempitem.wpn7 = 0;
8203 81 tempitem.wpn8 = 0;
8204 81 tempitem.wpn9 = 0;
8205 81 tempitem.wpn10 = 0;
8206 81 break;
8207 }
8208 case itype_hammer:
8209 {
8210 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8211 81 tempitem.misc1 = 0;
8212 81 tempitem.misc2 = 0;
8213 81 tempitem.misc3 = 0;
8214 81 tempitem.misc4 = 0;
8215 81 tempitem.misc5 = 0;
8216 81 tempitem.misc6 = 0;
8217 81 tempitem.misc7 = 0;
8218 81 tempitem.misc8 = 0;
8219 81 tempitem.misc9 = 0;
8220 81 tempitem.misc10 = 0;
8221 81 tempitem.wpn3 = 0;
8222 81 tempitem.wpn4 = 0;
8223 81 tempitem.wpn5 = 0;
8224 81 tempitem.wpn6 = 0;
8225 81 tempitem.wpn7 = 0;
8226 81 tempitem.wpn8 = 0;
8227 81 tempitem.wpn9 = 0;
8228 81 tempitem.wpn10 = 0;
8229 81 break;
8230 }
8231 case itype_divinefire:
8232 {
8233 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8234 81 tempitem.misc3 = 0;
8235 81 tempitem.misc4 = 0;
8236 81 tempitem.misc5 = 0;
8237 81 tempitem.misc6 = 0;
8238 81 tempitem.misc7 = 0;
8239 81 tempitem.misc8 = 0;
8240 81 tempitem.misc9 = 0;
8241 81 tempitem.misc10 = 0;
8242 81 tempitem.wpn6 = 0;
8243 81 tempitem.wpn7 = 0;
8244 81 tempitem.wpn8 = 0;
8245 81 tempitem.wpn9 = 0;
8246 81 tempitem.wpn10 = 0;
8247 81 break;
8248 }
8249 case itype_divineescape:
8250 {
8251 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8252 81 tempitem.misc2 = 0;
8253 81 tempitem.misc3 = 0;
8254 81 tempitem.misc4 = 0;
8255 81 tempitem.misc5 = 0;
8256 81 tempitem.misc6 = 0;
8257 81 tempitem.misc7 = 0;
8258 81 tempitem.misc8 = 0;
8259 81 tempitem.misc9 = 0;
8260 81 tempitem.misc10 = 0;
8261 81 tempitem.wpn = 0;
8262 81 tempitem.wpn2 = 0;
8263 81 tempitem.wpn3 = 0;
8264 81 tempitem.wpn4 = 0;
8265 81 tempitem.wpn5 = 0;
8266 81 tempitem.wpn6 = 0;
8267 81 tempitem.wpn7 = 0;
8268 81 tempitem.wpn8 = 0;
8269 81 tempitem.wpn9 = 0;
8270 81 tempitem.wpn10 = 0;
8271 81 break;
8272 }
8273 case itype_divineprotection:
8274 {
8275 81 tempitem.flags &= ~ (ITEM_FLAG5);
8276 81 tempitem.misc2 = 0;
8277 81 tempitem.misc3 = 0;
8278 81 tempitem.misc4 = 0;
8279 81 tempitem.misc5 = 0;
8280 81 tempitem.misc6 = 0;
8281 81 tempitem.misc7 = 0;
8282 81 tempitem.misc8 = 0;
8283 81 tempitem.misc9 = 0;
8284 81 tempitem.misc10 = 0;
8285 81 break;
8286 }
8287 case itype_bomb:
8288 {
8289 96 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8290 96 tempitem.misc4 = 0;
8291 96 tempitem.misc5 = 0;
8292 96 tempitem.misc6 = 0;
8293 96 tempitem.misc7 = 0;
8294 96 tempitem.misc8 = 0;
8295 96 tempitem.misc9 = 0;
8296 96 tempitem.misc10 = 0;
8297 96 tempitem.wpn3 = 0;
8298 96 tempitem.wpn4 = 0;
8299 96 tempitem.wpn5 = 0;
8300 96 tempitem.wpn6 = 0;
8301 96 tempitem.wpn7 = 0;
8302 96 tempitem.wpn8 = 0;
8303 96 tempitem.wpn9 = 0;
8304 96 tempitem.wpn10 = 0;
8305 96 break;
8306 }
8307 case itype_sbomb:
8308 {
8309 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8310 81 tempitem.misc4 = 0;
8311 81 tempitem.misc5 = 0;
8312 81 tempitem.misc6 = 0;
8313 81 tempitem.misc7 = 0;
8314 81 tempitem.misc8 = 0;
8315 81 tempitem.misc9 = 0;
8316 81 tempitem.misc10 = 0;
8317 81 tempitem.wpn3 = 0;
8318 81 tempitem.wpn4 = 0;
8319 81 tempitem.wpn5 = 0;
8320 81 tempitem.wpn6 = 0;
8321 81 tempitem.wpn7 = 0;
8322 81 tempitem.wpn8 = 0;
8323 81 tempitem.wpn9 = 0;
8324 81 tempitem.wpn10 = 0;
8325 81 break;
8326 }
8327 case itype_clock:
8328 {
8329 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8330 81 tempitem.misc2 = 0;
8331 81 tempitem.misc3 = 0;
8332 81 tempitem.misc4 = 0;
8333 81 tempitem.misc5 = 0;
8334 81 tempitem.misc6 = 0;
8335 81 tempitem.misc7 = 0;
8336 81 tempitem.misc8 = 0;
8337 81 tempitem.misc9 = 0;
8338 81 tempitem.misc10 = 0;
8339 81 tempitem.wpn = 0;
8340 81 tempitem.wpn2 = 0;
8341 81 tempitem.wpn3 = 0;
8342 81 tempitem.wpn4 = 0;
8343 81 tempitem.wpn5 = 0;
8344 81 tempitem.wpn6 = 0;
8345 81 tempitem.wpn7 = 0;
8346 81 tempitem.wpn8 = 0;
8347 81 tempitem.wpn9 = 0;
8348 81 tempitem.wpn10 = 0;
8349 81 break;
8350 }
8351 case itype_key:
8352 {
8353 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8354 81 tempitem.misc1 = 0;
8355 81 tempitem.misc2 = 0;
8356 81 tempitem.misc3 = 0;
8357 81 tempitem.misc4 = 0;
8358 81 tempitem.misc5 = 0;
8359 81 tempitem.misc6 = 0;
8360 81 tempitem.misc7 = 0;
8361 81 tempitem.misc8 = 0;
8362 81 tempitem.misc9 = 0;
8363 81 tempitem.misc10 = 0;
8364 81 tempitem.wpn = 0;
8365 81 tempitem.wpn2 = 0;
8366 81 tempitem.wpn3 = 0;
8367 81 tempitem.wpn4 = 0;
8368 81 tempitem.wpn5 = 0;
8369 81 tempitem.wpn6 = 0;
8370 81 tempitem.wpn7 = 0;
8371 81 tempitem.wpn8 = 0;
8372 81 tempitem.wpn9 = 0;
8373 81 tempitem.wpn10 = 0;
8374 81 break;
8375 }
8376 case itype_magiccontainer:
8377 {
8378 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8379 81 tempitem.misc1 = 0;
8380 81 tempitem.misc2 = 0;
8381 81 tempitem.misc3 = 0;
8382 81 tempitem.misc4 = 0;
8383 81 tempitem.misc5 = 0;
8384 81 tempitem.misc6 = 0;
8385 81 tempitem.misc7 = 0;
8386 81 tempitem.misc8 = 0;
8387 81 tempitem.misc9 = 0;
8388 81 tempitem.misc10 = 0;
8389 81 tempitem.wpn = 0;
8390 81 tempitem.wpn2 = 0;
8391 81 tempitem.wpn3 = 0;
8392 81 tempitem.wpn4 = 0;
8393 81 tempitem.wpn5 = 0;
8394 81 tempitem.wpn6 = 0;
8395 81 tempitem.wpn7 = 0;
8396 81 tempitem.wpn8 = 0;
8397 81 tempitem.wpn9 = 0;
8398 81 tempitem.wpn10 = 0;
8399 81 break;
8400 }
8401 case itype_triforcepiece:
8402 {
8403 162 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8404 162 tempitem.misc3 = 0;
8405 162 tempitem.misc4 = 0;
8406 162 tempitem.misc5 = 0;
8407 162 tempitem.misc6 = 0;
8408 162 tempitem.misc7 = 0;
8409 162 tempitem.misc8 = 0;
8410 162 tempitem.misc9 = 0;
8411 162 tempitem.misc10 = 0;
8412 162 tempitem.wpn = 0;
8413 162 tempitem.wpn2 = 0;
8414 162 tempitem.wpn3 = 0;
8415 162 tempitem.wpn4 = 0;
8416 162 tempitem.wpn5 = 0;
8417 162 tempitem.wpn6 = 0;
8418 162 tempitem.wpn7 = 0;
8419 162 tempitem.wpn8 = 0;
8420 162 tempitem.wpn9 = 0;
8421 162 tempitem.wpn10 = 0;
8422 162 break;
8423 }
8424 case itype_map: case itype_compass: case itype_bosskey:
8425 {
8426 243 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8427 243 tempitem.misc1 = 0;
8428 243 tempitem.misc2 = 0;
8429 243 tempitem.misc3 = 0;
8430 243 tempitem.misc4 = 0;
8431 243 tempitem.misc5 = 0;
8432 243 tempitem.misc6 = 0;
8433 243 tempitem.misc7 = 0;
8434 243 tempitem.misc8 = 0;
8435 243 tempitem.misc9 = 0;
8436 243 tempitem.misc10 = 0;
8437 243 tempitem.wpn = 0;
8438 243 tempitem.wpn2 = 0;
8439 243 tempitem.wpn3 = 0;
8440 243 tempitem.wpn4 = 0;
8441 243 tempitem.wpn5 = 0;
8442 243 tempitem.wpn6 = 0;
8443 243 tempitem.wpn7 = 0;
8444 243 tempitem.wpn8 = 0;
8445 243 tempitem.wpn9 = 0;
8446 243 tempitem.wpn10 = 0;
8447 243 break;
8448 }
8449 case itype_quiver:
8450 {
8451 324 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8452 324 tempitem.misc3 = 0;
8453 324 tempitem.misc4 = 0;
8454 324 tempitem.misc5 = 0;
8455 324 tempitem.misc6 = 0;
8456 324 tempitem.misc7 = 0;
8457 324 tempitem.misc8 = 0;
8458 324 tempitem.misc9 = 0;
8459 324 tempitem.misc10 = 0;
8460 324 tempitem.wpn = 0;
8461 324 tempitem.wpn2 = 0;
8462 324 tempitem.wpn3 = 0;
8463 324 tempitem.wpn4 = 0;
8464 324 tempitem.wpn5 = 0;
8465 324 tempitem.wpn6 = 0;
8466 324 tempitem.wpn7 = 0;
8467 324 tempitem.wpn8 = 0;
8468 324 tempitem.wpn9 = 0;
8469 324 tempitem.wpn10 = 0;
8470 324 break;
8471 }
8472 case itype_lkey:
8473 {
8474 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8475 81 tempitem.misc1 = 0;
8476 81 tempitem.misc2 = 0;
8477 81 tempitem.misc3 = 0;
8478 81 tempitem.misc4 = 0;
8479 81 tempitem.misc5 = 0;
8480 81 tempitem.misc6 = 0;
8481 81 tempitem.misc7 = 0;
8482 81 tempitem.misc8 = 0;
8483 81 tempitem.misc9 = 0;
8484 81 tempitem.misc10 = 0;
8485 81 tempitem.wpn = 0;
8486 81 tempitem.wpn2 = 0;
8487 81 tempitem.wpn3 = 0;
8488 81 tempitem.wpn4 = 0;
8489 81 tempitem.wpn5 = 0;
8490 81 tempitem.wpn6 = 0;
8491 81 tempitem.wpn7 = 0;
8492 81 tempitem.wpn8 = 0;
8493 81 tempitem.wpn9 = 0;
8494 81 tempitem.wpn10 = 0;
8495 81 break;
8496 }
8497 case itype_cbyrna:
8498 {
8499 81 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8500 81 tempitem.misc4 = 0;
8501 81 tempitem.misc5 = 0;
8502 81 tempitem.misc6 = 0;
8503 81 tempitem.misc7 = 0;
8504 81 tempitem.misc8 = 0;
8505 81 tempitem.misc9 = 0;
8506 81 tempitem.misc10 = 0;
8507 81 tempitem.wpn6 = 0;
8508 81 tempitem.wpn7 = 0;
8509 81 tempitem.wpn8 = 0;
8510 81 tempitem.wpn9 = 0;
8511 81 tempitem.wpn10 = 0;
8512 81 break;
8513 }
8514 case itype_rupee: case itype_arrowammo:
8515 {
8516 1014 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8517 1014 tempitem.misc1 = 0;
8518 1014 tempitem.misc2 = 0;
8519 1014 tempitem.misc3 = 0;
8520 1014 tempitem.misc4 = 0;
8521 1014 tempitem.misc5 = 0;
8522 1014 tempitem.misc6 = 0;
8523 1014 tempitem.misc7 = 0;
8524 1014 tempitem.misc8 = 0;
8525 1014 tempitem.misc9 = 0;
8526 1014 tempitem.misc10 = 0;
8527 1014 tempitem.wpn = 0;
8528 1014 tempitem.wpn2 = 0;
8529 1014 tempitem.wpn3 = 0;
8530 1014 tempitem.wpn4 = 0;
8531 1014 tempitem.wpn5 = 0;
8532 1014 tempitem.wpn6 = 0;
8533 1014 tempitem.wpn7 = 0;
8534 1014 tempitem.wpn8 = 0;
8535 1014 tempitem.wpn9 = 0;
8536 1014 tempitem.wpn10 = 0;
8537 1014 break;
8538 }
8539 case itype_fairy:
8540 {
8541 144 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8542 144 tempitem.misc4 = 0;
8543 144 tempitem.misc5 = 0;
8544 144 tempitem.misc6 = 0;
8545 144 tempitem.misc7 = 0;
8546 144 tempitem.misc8 = 0;
8547 144 tempitem.misc9 = 0;
8548 144 tempitem.misc10 = 0;
8549 144 tempitem.wpn = 0;
8550 144 tempitem.wpn2 = 0;
8551 144 tempitem.wpn3 = 0;
8552 144 tempitem.wpn4 = 0;
8553 144 tempitem.wpn5 = 0;
8554 144 tempitem.wpn6 = 0;
8555 144 tempitem.wpn7 = 0;
8556 144 tempitem.wpn8 = 0;
8557 144 tempitem.wpn9 = 0;
8558 144 tempitem.wpn10 = 0;
8559 144 break;
8560 }
8561 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8562 {
8563 867 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8564 867 tempitem.misc1 = 0;
8565 867 tempitem.misc2 = 0;
8566 867 tempitem.misc3 = 0;
8567 867 tempitem.misc4 = 0;
8568 867 tempitem.misc5 = 0;
8569 867 tempitem.misc6 = 0;
8570 867 tempitem.misc7 = 0;
8571 867 tempitem.misc8 = 0;
8572 867 tempitem.misc9 = 0;
8573 867 tempitem.misc10 = 0;
8574 867 tempitem.wpn = 0;
8575 867 tempitem.wpn2 = 0;
8576 867 tempitem.wpn3 = 0;
8577 867 tempitem.wpn4 = 0;
8578 867 tempitem.wpn5 = 0;
8579 867 tempitem.wpn6 = 0;
8580 867 tempitem.wpn7 = 0;
8581 867 tempitem.wpn8 = 0;
8582 867 tempitem.wpn9 = 0;
8583 867 tempitem.wpn10 = 0;
8584 867 break;
8585 }
8586 case itype_bombbag:
8587 {
8588 324 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8589 324 tempitem.misc3 = 0;
8590 324 tempitem.misc4 = 0;
8591 324 tempitem.misc5 = 0;
8592 324 tempitem.misc6 = 0;
8593 324 tempitem.misc7 = 0;
8594 324 tempitem.misc8 = 0;
8595 324 tempitem.misc9 = 0;
8596 324 tempitem.misc10 = 0;
8597 324 tempitem.wpn = 0;
8598 324 tempitem.wpn2 = 0;
8599 324 tempitem.wpn3 = 0;
8600 324 tempitem.wpn4 = 0;
8601 324 tempitem.wpn5 = 0;
8602 324 tempitem.wpn6 = 0;
8603 324 tempitem.wpn7 = 0;
8604 324 tempitem.wpn8 = 0;
8605 324 tempitem.wpn9 = 0;
8606 324 tempitem.wpn10 = 0;
8607 324 break;
8608 }
8609 case itype_rocs:
8610 {
8611 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8612 81 tempitem.misc1 = 0;
8613 81 tempitem.misc2 = 0;
8614 81 tempitem.misc3 = 0;
8615 81 tempitem.misc4 = 0;
8616 81 tempitem.misc5 = 0;
8617 81 tempitem.misc6 = 0;
8618 81 tempitem.misc7 = 0;
8619 81 tempitem.misc8 = 0;
8620 81 tempitem.misc9 = 0;
8621 81 tempitem.misc10 = 0;
8622 81 tempitem.wpn = 0;
8623 81 tempitem.wpn2 = 0;
8624 81 tempitem.wpn3 = 0;
8625 81 tempitem.wpn4 = 0;
8626 81 tempitem.wpn5 = 0;
8627 81 tempitem.wpn6 = 0;
8628 81 tempitem.wpn7 = 0;
8629 81 tempitem.wpn8 = 0;
8630 81 tempitem.wpn9 = 0;
8631 81 tempitem.wpn10 = 0;
8632 81 break;
8633 }
8634 case itype_hoverboots:
8635 {
8636 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8637 81 tempitem.misc2 = 0;
8638 81 tempitem.misc3 = 0;
8639 81 tempitem.misc4 = 0;
8640 81 tempitem.misc5 = 0;
8641 81 tempitem.misc6 = 0;
8642 81 tempitem.misc7 = 0;
8643 81 tempitem.misc8 = 0;
8644 81 tempitem.misc9 = 0;
8645 81 tempitem.misc10 = 0;
8646 81 tempitem.wpn2 = 0;
8647 81 tempitem.wpn3 = 0;
8648 81 tempitem.wpn4 = 0;
8649 81 tempitem.wpn5 = 0;
8650 81 tempitem.wpn6 = 0;
8651 81 tempitem.wpn7 = 0;
8652 81 tempitem.wpn8 = 0;
8653 81 tempitem.wpn9 = 0;
8654 81 tempitem.wpn10 = 0;
8655 81 break;
8656 }
8657 case itype_spinscroll:
8658 {
8659 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8660 81 tempitem.misc2 = 0;
8661 81 tempitem.misc3 = 0;
8662 81 tempitem.misc4 = 0;
8663 81 tempitem.misc5 = 0;
8664 81 tempitem.misc6 = 0;
8665 81 tempitem.misc7 = 0;
8666 81 tempitem.misc8 = 0;
8667 81 tempitem.misc9 = 0;
8668 81 tempitem.misc10 = 0;
8669 81 tempitem.wpn = 0;
8670 81 tempitem.wpn2 = 0;
8671 81 tempitem.wpn3 = 0;
8672 81 tempitem.wpn4 = 0;
8673 81 tempitem.wpn5 = 0;
8674 81 tempitem.wpn6 = 0;
8675 81 tempitem.wpn7 = 0;
8676 81 tempitem.wpn8 = 0;
8677 81 tempitem.wpn9 = 0;
8678 81 tempitem.wpn10 = 0;
8679 81 break;
8680 }
8681 case itype_crossscroll:
8682 {
8683 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8684 81 tempitem.misc1 = 0;
8685 81 tempitem.misc2 = 0;
8686 81 tempitem.misc3 = 0;
8687 81 tempitem.misc4 = 0;
8688 81 tempitem.misc5 = 0;
8689 81 tempitem.misc6 = 0;
8690 81 tempitem.misc7 = 0;
8691 81 tempitem.misc8 = 0;
8692 81 tempitem.misc9 = 0;
8693 81 tempitem.misc10 = 0;
8694 81 tempitem.wpn = 0;
8695 81 tempitem.wpn2 = 0;
8696 81 tempitem.wpn3 = 0;
8697 81 tempitem.wpn4 = 0;
8698 81 tempitem.wpn5 = 0;
8699 81 tempitem.wpn6 = 0;
8700 81 tempitem.wpn7 = 0;
8701 81 tempitem.wpn8 = 0;
8702 81 tempitem.wpn9 = 0;
8703 81 tempitem.wpn10 = 0;
8704 81 break;
8705 }
8706 case itype_quakescroll:
8707 {
8708 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8709 81 tempitem.misc3 = 0;
8710 81 tempitem.misc4 = 0;
8711 81 tempitem.misc5 = 0;
8712 81 tempitem.misc6 = 0;
8713 81 tempitem.misc7 = 0;
8714 81 tempitem.misc8 = 0;
8715 81 tempitem.misc9 = 0;
8716 81 tempitem.misc10 = 0;
8717 81 tempitem.wpn = 0;
8718 81 tempitem.wpn2 = 0;
8719 81 tempitem.wpn3 = 0;
8720 81 tempitem.wpn4 = 0;
8721 81 tempitem.wpn5 = 0;
8722 81 tempitem.wpn6 = 0;
8723 81 tempitem.wpn7 = 0;
8724 81 tempitem.wpn8 = 0;
8725 81 tempitem.wpn9 = 0;
8726 81 tempitem.wpn10 = 0;
8727 81 break;
8728 }
8729 case itype_whispring:
8730 {
8731 162 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8732 162 tempitem.misc2 = 0;
8733 162 tempitem.misc3 = 0;
8734 162 tempitem.misc4 = 0;
8735 162 tempitem.misc5 = 0;
8736 162 tempitem.misc6 = 0;
8737 162 tempitem.misc7 = 0;
8738 162 tempitem.misc8 = 0;
8739 162 tempitem.misc9 = 0;
8740 162 tempitem.misc10 = 0;
8741 162 tempitem.wpn = 0;
8742 162 tempitem.wpn2 = 0;
8743 162 tempitem.wpn3 = 0;
8744 162 tempitem.wpn4 = 0;
8745 162 tempitem.wpn5 = 0;
8746 162 tempitem.wpn6 = 0;
8747 162 tempitem.wpn7 = 0;
8748 162 tempitem.wpn8 = 0;
8749 162 tempitem.wpn9 = 0;
8750 162 tempitem.wpn10 = 0;
8751 162 break;
8752 }
8753 case itype_chargering:
8754 {
8755 162 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8756 162 tempitem.misc3 = 0;
8757 162 tempitem.misc4 = 0;
8758 162 tempitem.misc5 = 0;
8759 162 tempitem.misc6 = 0;
8760 162 tempitem.misc7 = 0;
8761 162 tempitem.misc8 = 0;
8762 162 tempitem.misc9 = 0;
8763 162 tempitem.misc10 = 0;
8764 162 tempitem.wpn = 0;
8765 162 tempitem.wpn2 = 0;
8766 162 tempitem.wpn3 = 0;
8767 162 tempitem.wpn4 = 0;
8768 162 tempitem.wpn5 = 0;
8769 162 tempitem.wpn6 = 0;
8770 162 tempitem.wpn7 = 0;
8771 162 tempitem.wpn8 = 0;
8772 162 tempitem.wpn9 = 0;
8773 162 tempitem.wpn10 = 0;
8774 162 break;
8775 }
8776 case itype_perilscroll:
8777 {
8778 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8779 81 tempitem.misc2 = 0;
8780 81 tempitem.misc3 = 0;
8781 81 tempitem.misc4 = 0;
8782 81 tempitem.misc5 = 0;
8783 81 tempitem.misc6 = 0;
8784 81 tempitem.misc7 = 0;
8785 81 tempitem.misc8 = 0;
8786 81 tempitem.misc9 = 0;
8787 81 tempitem.misc10 = 0;
8788 81 tempitem.wpn = 0;
8789 81 tempitem.wpn2 = 0;
8790 81 tempitem.wpn3 = 0;
8791 81 tempitem.wpn4 = 0;
8792 81 tempitem.wpn5 = 0;
8793 81 tempitem.wpn6 = 0;
8794 81 tempitem.wpn7 = 0;
8795 81 tempitem.wpn8 = 0;
8796 81 tempitem.wpn9 = 0;
8797 81 tempitem.wpn10 = 0;
8798 81 break;
8799 }
8800 case itype_wealthmedal:
8801 {
8802 243 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8803 243 tempitem.misc2 = 0;
8804 243 tempitem.misc3 = 0;
8805 243 tempitem.misc4 = 0;
8806 243 tempitem.misc5 = 0;
8807 243 tempitem.misc6 = 0;
8808 243 tempitem.misc7 = 0;
8809 243 tempitem.misc8 = 0;
8810 243 tempitem.misc9 = 0;
8811 243 tempitem.misc10 = 0;
8812 243 tempitem.wpn = 0;
8813 243 tempitem.wpn2 = 0;
8814 243 tempitem.wpn3 = 0;
8815 243 tempitem.wpn4 = 0;
8816 243 tempitem.wpn5 = 0;
8817 243 tempitem.wpn6 = 0;
8818 243 tempitem.wpn7 = 0;
8819 243 tempitem.wpn8 = 0;
8820 243 tempitem.wpn9 = 0;
8821 243 tempitem.wpn10 = 0;
8822 243 break;
8823 }
8824 case itype_heartring:
8825 {
8826 243 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8827 243 tempitem.misc3 = 0;
8828 243 tempitem.misc4 = 0;
8829 243 tempitem.misc5 = 0;
8830 243 tempitem.misc6 = 0;
8831 243 tempitem.misc7 = 0;
8832 243 tempitem.misc8 = 0;
8833 243 tempitem.misc9 = 0;
8834 243 tempitem.misc10 = 0;
8835 243 tempitem.wpn = 0;
8836 243 tempitem.wpn2 = 0;
8837 243 tempitem.wpn3 = 0;
8838 243 tempitem.wpn4 = 0;
8839 243 tempitem.wpn5 = 0;
8840 243 tempitem.wpn6 = 0;
8841 243 tempitem.wpn7 = 0;
8842 243 tempitem.wpn8 = 0;
8843 243 tempitem.wpn9 = 0;
8844 243 tempitem.wpn10 = 0;
8845 243 break;
8846 }
8847 case itype_magicring:
8848 {
8849 324 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8850 324 tempitem.misc3 = 0;
8851 324 tempitem.misc4 = 0;
8852 324 tempitem.misc5 = 0;
8853 324 tempitem.misc6 = 0;
8854 324 tempitem.misc7 = 0;
8855 324 tempitem.misc8 = 0;
8856 324 tempitem.misc9 = 0;
8857 324 tempitem.misc10 = 0;
8858 324 tempitem.wpn = 0;
8859 324 tempitem.wpn2 = 0;
8860 324 tempitem.wpn3 = 0;
8861 324 tempitem.wpn4 = 0;
8862 324 tempitem.wpn5 = 0;
8863 324 tempitem.wpn6 = 0;
8864 324 tempitem.wpn7 = 0;
8865 324 tempitem.wpn8 = 0;
8866 324 tempitem.wpn9 = 0;
8867 324 tempitem.wpn10 = 0;
8868 324 break;
8869 }
8870 case itype_spinscroll2:
8871 {
8872 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8873 81 tempitem.misc2 = 0;
8874 81 tempitem.misc3 = 0;
8875 81 tempitem.misc4 = 0;
8876 81 tempitem.misc5 = 0;
8877 81 tempitem.misc6 = 0;
8878 81 tempitem.misc7 = 0;
8879 81 tempitem.misc8 = 0;
8880 81 tempitem.misc9 = 0;
8881 81 tempitem.misc10 = 0;
8882 81 tempitem.wpn = 0;
8883 81 tempitem.wpn2 = 0;
8884 81 tempitem.wpn3 = 0;
8885 81 tempitem.wpn4 = 0;
8886 81 tempitem.wpn5 = 0;
8887 81 tempitem.wpn6 = 0;
8888 81 tempitem.wpn7 = 0;
8889 81 tempitem.wpn8 = 0;
8890 81 tempitem.wpn9 = 0;
8891 81 tempitem.wpn10 = 0;
8892 81 break;
8893 }
8894 case itype_quakescroll2:
8895 {
8896 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8897 81 tempitem.misc3 = 0;
8898 81 tempitem.misc4 = 0;
8899 81 tempitem.misc5 = 0;
8900 81 tempitem.misc6 = 0;
8901 81 tempitem.misc7 = 0;
8902 81 tempitem.misc8 = 0;
8903 81 tempitem.misc9 = 0;
8904 81 tempitem.misc10 = 0;
8905 81 tempitem.wpn = 0;
8906 81 tempitem.wpn2 = 0;
8907 81 tempitem.wpn3 = 0;
8908 81 tempitem.wpn4 = 0;
8909 81 tempitem.wpn5 = 0;
8910 81 tempitem.wpn6 = 0;
8911 81 tempitem.wpn7 = 0;
8912 81 tempitem.wpn8 = 0;
8913 81 tempitem.wpn9 = 0;
8914 81 tempitem.wpn10 = 0;
8915 81 break;
8916 }
8917 case itype_agony:
8918 {
8919 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8920 81 tempitem.misc2 = 0;
8921 81 tempitem.misc3 = 0;
8922 81 tempitem.misc4 = 0;
8923 81 tempitem.misc5 = 0;
8924 81 tempitem.misc6 = 0;
8925 81 tempitem.misc7 = 0;
8926 81 tempitem.misc8 = 0;
8927 81 tempitem.misc9 = 0;
8928 81 tempitem.misc10 = 0;
8929 81 tempitem.wpn = 0;
8930 81 tempitem.wpn2 = 0;
8931 81 tempitem.wpn3 = 0;
8932 81 tempitem.wpn4 = 0;
8933 81 tempitem.wpn5 = 0;
8934 81 tempitem.wpn6 = 0;
8935 81 tempitem.wpn7 = 0;
8936 81 tempitem.wpn8 = 0;
8937 81 tempitem.wpn9 = 0;
8938 81 tempitem.wpn10 = 0;
8939 81 break;
8940 }
8941 case itype_stompboots:
8942 {
8943 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8944 81 tempitem.misc1 = 0;
8945 81 tempitem.misc2 = 0;
8946 81 tempitem.misc3 = 0;
8947 81 tempitem.misc4 = 0;
8948 81 tempitem.misc5 = 0;
8949 81 tempitem.misc6 = 0;
8950 81 tempitem.misc7 = 0;
8951 81 tempitem.misc8 = 0;
8952 81 tempitem.misc9 = 0;
8953 81 tempitem.misc10 = 0;
8954 81 tempitem.wpn = 0;
8955 81 tempitem.wpn2 = 0;
8956 81 tempitem.wpn3 = 0;
8957 81 tempitem.wpn4 = 0;
8958 81 tempitem.wpn5 = 0;
8959 81 tempitem.wpn6 = 0;
8960 81 tempitem.wpn7 = 0;
8961 81 tempitem.wpn8 = 0;
8962 81 tempitem.wpn9 = 0;
8963 81 tempitem.wpn10 = 0;
8964 81 break;
8965 }
8966 case itype_whimsicalring:
8967 {
8968 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8969 81 tempitem.misc2 = 0;
8970 81 tempitem.misc3 = 0;
8971 81 tempitem.misc4 = 0;
8972 81 tempitem.misc5 = 0;
8973 81 tempitem.misc6 = 0;
8974 81 tempitem.misc7 = 0;
8975 81 tempitem.misc8 = 0;
8976 81 tempitem.misc9 = 0;
8977 81 tempitem.misc10 = 0;
8978 81 tempitem.wpn = 0;
8979 81 tempitem.wpn2 = 0;
8980 81 tempitem.wpn3 = 0;
8981 81 tempitem.wpn4 = 0;
8982 81 tempitem.wpn5 = 0;
8983 81 tempitem.wpn6 = 0;
8984 81 tempitem.wpn7 = 0;
8985 81 tempitem.wpn8 = 0;
8986 81 tempitem.wpn9 = 0;
8987 81 tempitem.wpn10 = 0;
8988 81 break;
8989 }
8990 case itype_perilring:
8991 {
8992 81 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8993 81 tempitem.misc2 = 0;
8994 81 tempitem.misc3 = 0;
8995 81 tempitem.misc4 = 0;
8996 81 tempitem.misc5 = 0;
8997 81 tempitem.misc6 = 0;
8998 81 tempitem.misc7 = 0;
8999 81 tempitem.misc8 = 0;
9000 81 tempitem.misc9 = 0;
9001 81 tempitem.misc10 = 0;
9002 81 tempitem.wpn = 0;
9003 81 tempitem.wpn2 = 0;
9004 81 tempitem.wpn3 = 0;
9005 81 tempitem.wpn4 = 0;
9006 81 tempitem.wpn5 = 0;
9007 81 tempitem.wpn6 = 0;
9008 81 tempitem.wpn7 = 0;
9009 81 tempitem.wpn8 = 0;
9010 81 tempitem.wpn9 = 0;
9011 81 tempitem.wpn10 = 0;
9012 81 break;
9013 }
9014 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9015 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9016 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9017 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9018 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9019 {
9020 2037 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9021 2037 tempitem.misc1 = 0;
9022 2037 tempitem.misc2 = 0;
9023 2037 tempitem.misc3 = 0;
9024 2037 tempitem.misc4 = 0;
9025 2037 tempitem.misc5 = 0;
9026 2037 tempitem.misc6 = 0;
9027 2037 tempitem.misc7 = 0;
9028 2037 tempitem.misc8 = 0;
9029 2037 tempitem.misc9 = 0;
9030 2037 tempitem.misc10 = 0;
9031 2037 tempitem.wpn = 0;
9032 2037 tempitem.wpn2 = 0;
9033 2037 tempitem.wpn3 = 0;
9034 2037 tempitem.wpn4 = 0;
9035 2037 tempitem.wpn5 = 0;
9036 2037 tempitem.wpn6 = 0;
9037 2037 tempitem.wpn7 = 0;
9038 2037 tempitem.wpn8 = 0;
9039 2037 tempitem.wpn9 = 0;
9040 2037 tempitem.wpn10 = 0;
9041 2037 break;
9042 }
9043 }
9044 20736 }
9045 //Port quest rules to items
9046
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version <= 31)
9047 {
9048
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 20640 times.
20736 if(tempitem.family == itype_bomb)
9049 {
9050
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 86 times.
96 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9051 86 else tempitem.flags &= ~ ITEM_FLAG2;
9052 96 }
9053
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 20559 times.
20640 else if(tempitem.family == itype_sbomb)
9054 {
9055
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 71 times.
81 if ( get_bit(quest_rules,qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9056 71 else tempitem.flags &= ~ ITEM_FLAG2;
9057 81 }
9058
9059
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 20316 times.
20559 else if(tempitem.family == itype_brang)
9060 {
9061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 243 times.
243 if ( get_bit(quest_rules,qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9062 243 else tempitem.flags &= ~ ITEM_FLAG4;
9063 243 }
9064
2/2
✓ Branch 0 taken 20220 times.
✓ Branch 1 taken 96 times.
20316 else if(tempitem.family == itype_wand)
9065 {
9066
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 94 times.
96 if ( get_bit(quest_rules,qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9067 94 else tempitem.flags &= ~ ITEM_FLAG3;
9068 96 }
9069 20736 }
9070
9071 //Port quest rules to items
9072
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version <= 37)
9073 {
9074
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 20655 times.
20736 if(tempitem.family == itype_flippers)
9075 {
9076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if ( (get_bit(quest_rules,qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9077 81 else tempitem.flags &= ~ ITEM_FLAG1;
9078 81 }
9079
2/2
✓ Branch 0 taken 13859 times.
✓ Branch 1 taken 6796 times.
20655 else if(tempitem.family == itype_sword)
9080 {
9081
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6727 times.
6796 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9082 6727 else tempitem.flags &= ~ ITEM_FLAG5;
9083 6796 }
9084
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 13763 times.
13859 else if(tempitem.family == itype_wand)
9085 {
9086
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 93 times.
96 if ( (get_bit(quest_rules,qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9087 93 else tempitem.flags &= ~ ITEM_FLAG5;
9088 96 }
9089
4/4
✓ Branch 0 taken 13667 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 200 times.
✓ Branch 3 taken 13467 times.
13763 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9090 {
9091 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9092
2/2
✓ Branch 0 taken 66 times.
✓ Branch 1 taken 230 times.
296 if ( (get_bit(quest_rules,qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9093 230 else tempitem.flags &= ~ ITEM_FLAG3;
9094 296 }
9095 20736 }
9096
9097
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 38)
9098 {
9099
4/4
✓ Branch 0 taken 20493 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 162 times.
✓ Branch 3 taken 20331 times.
20736 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9100 {
9101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 405 times.
405 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9102 405 else tempitem.flags &= ~ITEM_FLAG4;
9103
9104
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 395 times.
405 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9105 395 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9106 405 }
9107
2/2
✓ Branch 0 taken 20090 times.
✓ Branch 1 taken 241 times.
20331 else if(tempitem.family == itype_arrow)
9108 {
9109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 241 times.
241 if(get_bit(quest_rules,qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9110 241 else tempitem.flags &= ~ITEM_FLAG4;
9111
9112
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 237 times.
241 if(get_bit(quest_rules,qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9113 237 else tempitem.flags |= ITEM_FLAG2;
9114 241 }
9115 20736 }
9116
9117
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 39)
9118 {
9119
6/6
✓ Branch 0 taken 20655 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 20559 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 200 times.
✓ Branch 5 taken 20359 times.
20736 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9120 {
9121
2/2
✓ Branch 0 taken 365 times.
✓ Branch 1 taken 12 times.
377 if(get_bit(quest_rules,qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9122 365 else tempitem.flags &= ~ITEM_FLAG5;
9123 377 }
9124
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 20198 times.
20359 else if(tempitem.family == itype_potion)
9125 {
9126
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 151 times.
161 if(get_bit(quest_rules,qr_NONBUBBLEMEDICINE))
9127 {
9128 10 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9129 10 }
9130 else
9131 {
9132 151 tempitem.flags |= ITEM_FLAG3;
9133
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 66 times.
151 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9134 66 else tempitem.flags &= ~ITEM_FLAG4;
9135 }
9136 161 }
9137
2/2
✓ Branch 0 taken 20036 times.
✓ Branch 1 taken 162 times.
20198 else if(tempitem.family == itype_triforcepiece)
9138 {
9139
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 146 times.
162 if(get_bit(quest_rules,qr_NONBUBBLETRIFORCE))
9140 {
9141 16 tempitem.flags |= ITEM_FLAG3;
9142
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10 times.
16 if(get_bit(quest_rules,qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9143 10 else tempitem.flags &= ~ITEM_FLAG4;
9144 16 }
9145 else
9146 {
9147 146 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9148 }
9149 162 }
9150 20736 }
9151
9152
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 40)
9153 {
9154
4/4
✓ Branch 0 taken 20493 times.
✓ Branch 1 taken 243 times.
✓ Branch 2 taken 81 times.
✓ Branch 3 taken 20412 times.
20736 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9155 {
9156
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 304 times.
324 if(get_bit(quest_rules,qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9157 304 else tempitem.flags &= ~ITEM_FLAG1;
9158 324 }
9159
8/8
✓ Branch 0 taken 20212 times.
✓ Branch 1 taken 200 times.
✓ Branch 2 taken 13416 times.
✓ Branch 3 taken 6796 times.
✓ Branch 4 taken 13320 times.
✓ Branch 5 taken 96 times.
✓ Branch 6 taken 81 times.
✓ Branch 7 taken 13239 times.
20412 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9160 {
9161
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 7092 times.
7173 if(get_bit(quest_rules,qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9162 7092 else tempitem.flags &= ~ITEM_FLAG8;
9163 7173 }
9164
6/6
✓ Branch 0 taken 13940 times.
✓ Branch 1 taken 6796 times.
✓ Branch 2 taken 13844 times.
✓ Branch 3 taken 96 times.
✓ Branch 4 taken 81 times.
✓ Branch 5 taken 13763 times.
20736 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9165 {
9166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6973 times.
6973 if(get_bit(quest_rules,qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9167 6973 else tempitem.flags &= ~ITEM_FLAG7;
9168 6973 }
9169
2/2
✓ Branch 0 taken 13682 times.
✓ Branch 1 taken 81 times.
13763 else if(tempitem.family == itype_cbyrna)
9170 {
9171 81 tempitem.flags |= ITEM_FLAG7;
9172 81 }
9173 20736 }
9174
9175
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 41 )
9176 {
9177
2/2
✓ Branch 0 taken 13940 times.
✓ Branch 1 taken 6796 times.
20736 if(tempitem.family == itype_sword)
9178 {
9179
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6727 times.
6796 if(get_bit(quest_rules,qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9180 6727 else tempitem.flags &= ~ITEM_FLAG9;
9181
9182
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 6727 times.
6796 if(get_bit(quest_rules,qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9183 6727 else tempitem.flags &= ~ITEM_FLAG10;
9184 6796 }
9185 20736 }
9186
9187
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 42 )
9188 {
9189
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 20640 times.
20736 if(tempitem.family == itype_wand)
9190 {
9191
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 94 times.
96 if(get_bit(quest_rules,qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9192 94 else tempitem.flags &= ~ITEM_FLAG3;
9193
9194 96 tempitem.flags &= ~ITEM_FLAG6;
9195 96 }
9196
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 20559 times.
20640 else if(tempitem.family == itype_hammer)
9197 {
9198 81 tempitem.flags &= ~ITEM_FLAG3;
9199 81 }
9200
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 20478 times.
20559 else if(tempitem.family == itype_cbyrna)
9201 {
9202 81 tempitem.flags |= ITEM_FLAG3;
9203
9204 81 tempitem.flags &= ~ITEM_FLAG6;
9205 81 }
9206
2/2
✓ Branch 0 taken 13682 times.
✓ Branch 1 taken 6796 times.
20478 else if(tempitem.family == itype_sword)
9207 {
9208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796 times.
6796 if(get_bit(quest_rules,qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9209 6796 else tempitem.flags &= ~ITEM_FLAG6;
9210 6796 }
9211 20736 }
9212
9213
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 43 )
9214 {
9215
2/2
✓ Branch 0 taken 20609 times.
✓ Branch 1 taken 127 times.
20736 if(tempitem.family == itype_whistle)
9216 {
9217
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 124 times.
127 if(get_bit(quest_rules,qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9218 124 else tempitem.flags &= ~ITEM_FLAG3;
9219 127 }
9220 20736 }
9221
9222
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 45 )
9223 {
9224
2/2
✓ Branch 0 taken 20655 times.
✓ Branch 1 taken 81 times.
20736 if(tempitem.family == itype_flippers)
9225 {
9226 81 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9227 81 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9228 81 }
9229 20736 }
9230
9231
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 46 )
9232 {
9233
2/2
✓ Branch 0 taken 20655 times.
✓ Branch 1 taken 81 times.
20736 if(tempitem.family == itype_raft)
9234 {
9235 81 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9236 81 }
9237 20736 }
9238
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if ( s_version < 34 ) //! set the default counter for older quests.
9239 {
9240
2/2
✓ Branch 0 taken 71 times.
✓ Branch 1 taken 20665 times.
20736 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9241 {
9242 71 tempitem.cost_counter[0] = 1;
9243 71 }
9244 else
9245 {
9246
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 18105 times.
20665 if(get_bit(quest_rules,qr_ENABLEMAGIC))
9247 2560 tempitem.cost_counter[0] = 4;
9248 else
9249 {
9250 18105 tempitem.cost_amount[0] = 0;
9251 18105 tempitem.cost_counter[0] = -1;
9252 }
9253 }
9254 20736 }
9255
9256
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if ( s_version < 35 ) //new Lens of Truth flags
9257 {
9258
2/2
✓ Branch 0 taken 20655 times.
✓ Branch 1 taken 81 times.
20736 if ( tempitem.family == itype_lens )
9259 {
9260
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 78 times.
81 if ( get_bit(quest_rules,qr_RAFTLENS) )
9261 {
9262 3 tempitem.flags |= ITEM_FLAG4;
9263 3 }
9264
2/2
✓ Branch 0 taken 43 times.
✓ Branch 1 taken 38 times.
81 if ( get_bit(quest_rules,qr_LENSHINTS) )
9265 {
9266 43 tempitem.flags |= ITEM_FLAG1;
9267 43 }
9268
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 77 times.
81 if ( get_bit(quest_rules,qr_LENSSEESENEMIES) )
9269 {
9270 4 tempitem.flags |= ITEM_FLAG5;
9271 4 }
9272 81 }
9273 20736 }
9274
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9275 {
9276
2/2
✓ Branch 0 taken 165888 times.
✓ Branch 1 taken 20736 times.
186624 for ( int32_t q = 0; q < 8; q++ )
9277 {
9278 165888 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9279 165888 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9280 165888 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9281 165888 tempitem.sprite_initiald[q] = 0;
9282 165888 }
9283
2/2
✓ Branch 0 taken 41472 times.
✓ Branch 1 taken 20736 times.
62208 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9284 20736 tempitem.sprite_script = 0;
9285 20736 }
9286
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9287 {
9288 20736 tempitem.pickupflag = 0;
9289 20736 }
9290
9291
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 51 )
9292 {
9293
2/2
✓ Branch 0 taken 20536 times.
✓ Branch 1 taken 200 times.
20736 if( tempitem.family == itype_candle )
9294 {
9295 200 tempitem.misc4 = 50; //Step speed
9296 200 }
9297 20736 }
9298
9299
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if( s_version < 52 )
9300 {
9301
2/2
✓ Branch 0 taken 20493 times.
✓ Branch 1 taken 243 times.
20736 if( tempitem.family == itype_shield )
9302 243 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9303 20736 }
9304
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 20736 times.
26624 if(s_version < 53)
9305 {
9306
4/4
✓ Branch 0 taken 20318 times.
✓ Branch 1 taken 241 times.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 81 times.
20736 switch(tempitem.family)
9307 {
9308 case itype_arrow:
9309 241 tempitem.cost_counter[1] = crARROWS;
9310 241 tempitem.cost_amount[1] = 1;
9311 241 break;
9312 case itype_bomb:
9313 96 tempitem.cost_counter[1] = crBOMBS;
9314 96 tempitem.cost_amount[1] = 1;
9315 96 break;
9316 case itype_sbomb:
9317 81 tempitem.cost_counter[1] = crSBOMBS;
9318 81 tempitem.cost_amount[1] = 1;
9319 81 break;
9320 default:
9321 20318 tempitem.cost_counter[1] = crNONE;
9322 20318 tempitem.cost_amount[1] = 0;
9323 20318 }
9324 20736 tempitem.magiccosttimer[1] = 0;
9325 20736 }
9326
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
26624 if( s_version < 54 )
9327 {
9328
2/2
✓ Branch 0 taken 26519 times.
✓ Branch 1 taken 105 times.
26624 if( tempitem.family == itype_flippers )
9329 105 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9330 26624 }
9331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
26624 if(s_version < 55)
9332 {
9333
3/3
✓ Branch 0 taken 208 times.
✓ Branch 1 taken 208 times.
✓ Branch 2 taken 26208 times.
26624 switch(tempitem.family)
9334 {
9335 case itype_spinscroll:
9336 case itype_quakescroll:
9337 208 tempitem.usesound2 = WAV_ZN1CHARGE;
9338 208 break;
9339 case itype_spinscroll2:
9340 case itype_quakescroll2:
9341 208 tempitem.usesound2 = WAV_ZN1CHARGE2;
9342 208 break;
9343 }
9344 26624 }
9345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
26624 if(s_version < 56)
9346 {
9347
4/4
✓ Branch 0 taken 26153 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 119 times.
26624 switch(tempitem.family)
9348 {
9349 case itype_divinefire:
9350
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9351
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9352 104 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9353 104 break;
9354 case itype_candle:
9355
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 127 times.
248 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9356 248 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9357 248 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9358 248 break;
9359 case itype_book:
9360 119 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9361 119 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9362 119 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9363 119 break;
9364 }
9365 26624 }
9366
9367
2/2
✓ Branch 0 taken 938 times.
✓ Branch 1 taken 25686 times.
26624 if(tempitem.fam_type==0) // Always do this
9368 938 tempitem.fam_type=1;
9369
9370 26624 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9371 26624 }
9372 104 }
9373
9374 104 return 0;
9375 104 }
9376
9377 static bool did_init_def_items = false;
9378 53425 void init_def_items()
9379 {
9380
2/2
✓ Branch 0 taken 53394 times.
✓ Branch 1 taken 31 times.
53425 if(did_init_def_items) return;
9381 31 did_init_def_items = true;
9382 31 default_items[3].cost_counter[1] = crBOMBS;
9383 31 default_items[13].cost_counter[1] = crARROWS;
9384 31 default_items[14].cost_counter[1] = crARROWS;
9385 31 default_items[48].cost_counter[1] = crSBOMBS;
9386 31 default_items[57].cost_counter[1] = crARROWS;
9387 53425 }
9388 53425 void reset_itembuf(itemdata *item, int32_t id)
9389 {
9390 53425 init_def_items();
9391
2/2
✓ Branch 0 taken 23165 times.
✓ Branch 1 taken 30260 times.
53425 if(id<iLast)
9392 {
9393 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9394 30260 word tile = item->tile;
9395 30260 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9396 30260 int32_t ltm = item->ltm;
9397
9398 30260 memcpy(item,&default_items[id],sizeof(itemdata));
9399 30260 item->tile = tile;
9400 30260 item->misc_flags = miscs;
9401 30260 item->csets = cset;
9402 30260 item->frames = frames;
9403 30260 item->speed = speed;
9404 30260 item->delay = delay;
9405 30260 item->ltm = ltm;
9406 30260 }
9407 53425 }
9408
9409 9728 void reset_itemname(int32_t id)
9410 {
9411 9728 sprintf(item_string[id],"zz%03d",id);
9412
9413
2/2
✓ Branch 0 taken 4294 times.
✓ Branch 1 taken 5434 times.
9728 if(id < iLast)
9414 5434 strcpy(item_string[id],old_item_string[id]);
9415 9728 }
9416
9417 104 int32_t readweapons(PACKFILE *f, zquestheader *Header, bool keepdata)
9418 {
9419 104 word weapons_to_read=MAXWPNS;
9420 int32_t dummy;
9421 byte padding;
9422 wpndata tempweapon;
9423 104 word s_version=0, s_cversion=0;
9424
9425
9426
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x186)
9427 {
9428 weapons_to_read=64;
9429 }
9430
9431
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x185)
9432 {
9433 weapons_to_read=32;
9434 }
9435
9436
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
9437 {
9438 102 weapons_to_read=0;
9439
9440 //section version info
9441
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
9442 {
9443 return qe_invalid;
9444 }
9445
9446 102 FFCore.quest_format[vWeaponSprites] = s_version;
9447
9448 //al_trace("Weapons version %d\n", s_version);
9449
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_cversion,f,true))
9450 {
9451 return qe_invalid;
9452 }
9453
9454 //section size
9455
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
9456 {
9457 return qe_invalid;
9458 }
9459
9460 //finally... section data
9461
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&weapons_to_read,f,true))
9462 {
9463 return qe_invalid;
9464 }
9465 102 }
9466
9467
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version>2)
9468 {
9469
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i=0; i<weapons_to_read; i++)
9470 {
9471 char tempname[64];
9472
9473
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(!pfread(tempname, 64, f, keepdata))
9474 {
9475 return qe_invalid;
9476 }
9477
9478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24832 times.
24832 if(keepdata)
9479 {
9480 24832 strcpy(weapon_string[i], tempname);
9481 24832 }
9482 24832 }
9483
9484
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version<4)
9485 {
9486 if(keepdata)
9487 {
9488 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9489 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9490 }
9491 }
9492
9493
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version<5)
9494 {
9495 if(keepdata)
9496 {
9497 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9498 }
9499 }
9500
9501 /*
9502 if (s_version<6)
9503 {
9504 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9505 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9506 }
9507 */
9508 97 }
9509 else
9510 {
9511
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(keepdata)
9512
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<WPNCNT; i++)
9513 1799 reset_weaponname(i);
9514 }
9515
9516
2/2
✓ Branch 0 taken 25684 times.
✓ Branch 1 taken 104 times.
25788 for(int32_t i=0; i<weapons_to_read; i++)
9517 {
9518 25684 word oldtile = 0;
9519
2/2
✓ Branch 0 taken 3840 times.
✓ Branch 1 taken 21844 times.
25684 if (s_version < 8)
9520 {
9521
1/2
✓ Branch 0 taken 21844 times.
✗ Branch 1 not taken.
21844 if (!p_igetw(&oldtile, f, true))
9522 return qe_invalid;
9523 21844 }
9524
9525
1/2
✓ Branch 0 taken 25684 times.
✗ Branch 1 not taken.
25684 if(!p_getc(&tempweapon.misc,f,true))
9526 {
9527 return qe_invalid;
9528 }
9529
9530
1/2
✓ Branch 0 taken 25684 times.
✗ Branch 1 not taken.
25684 if(!p_getc(&tempweapon.csets,f,true))
9531 {
9532 return qe_invalid;
9533 }
9534
9535
1/2
✓ Branch 0 taken 25684 times.
✗ Branch 1 not taken.
25684 if(!p_getc(&tempweapon.frames,f,true))
9536 {
9537 return qe_invalid;
9538 }
9539
9540
1/2
✓ Branch 0 taken 25684 times.
✗ Branch 1 not taken.
25684 if(!p_getc(&tempweapon.speed,f,true))
9541 {
9542 return qe_invalid;
9543 }
9544
9545
1/2
✓ Branch 0 taken 25684 times.
✗ Branch 1 not taken.
25684 if(!p_getc(&tempweapon.type,f,true))
9546 {
9547 return qe_invalid;
9548 }
9549
9550
2/2
✓ Branch 0 taken 19796 times.
✓ Branch 1 taken 5888 times.
25684 if ( s_version >= 7 )
9551 {
9552
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetw(&tempweapon.script,f,true))
9553 {
9554 return qe_invalid;
9555 }
9556
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(!p_igetl(&tempweapon.tile,f,true))
9557 {
9558 return qe_invalid;
9559 }
9560 5888 }
9561
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 19796 times.
25684 if ( s_version < 7 )
9562 {
9563 19796 tempweapon.tile = oldtile;
9564 19796 }
9565
9566
2/2
✓ Branch 0 taken 25172 times.
✓ Branch 1 taken 512 times.
25684 if(Header->zelda_version < 0x193)
9567 {
9568
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 if(!p_getc(&padding,f,true))
9569 {
9570 return qe_invalid;
9571 }
9572 512 }
9573
9574
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 852 times.
25684 if(s_version < 6)
9575 {
9576
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 850 times.
852 if(i==ewFIRETRAIL)
9577 {
9578 2 tempweapon.misc |= WF_BEHIND;
9579 2 }
9580 else
9581 850 tempweapon.misc &= ~WF_BEHIND;
9582 852 }
9583
9584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25684 times.
25684 if(keepdata==true)
9585 {
9586 25684 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9587 25684 }
9588 25684 }
9589
9590
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
9591 {
9592
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<2)
9593 {
9594 7 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9595 7 }
9596
9597
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version<5)
9598 {
9599 7 wpnsbuf[iwQuarterHearts].tile=1;
9600 7 wpnsbuf[iwQuarterHearts].csets=1;
9601 7 }
9602
9603
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x176)
9604 {
9605 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9606 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9607 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9608 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9609 }
9610
9611
2/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
104 if((Header->zelda_version < 0x192)||
9612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9613 {
9614 2 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9615 2 }
9616
9617
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if((Header->zelda_version < 0x210))
9618 {
9619 2 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9620 2 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9621 2 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9622 2 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9623 2 }
9624 104 }
9625
9626 104 return 0;
9627 104 }
9628
9629 104 void init_guys(int32_t guyversion)
9630 {
9631
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<MAXGUYS; i++)
9632 {
9633 53248 guysbuf[i] = default_guys[0];
9634 53248 }
9635
9636
2/2
✓ Branch 0 taken 18408 times.
✓ Branch 1 taken 104 times.
18512 for(int32_t i=0; i<OLDMAXGUYS; i++)
9637 {
9638 18408 guysbuf[i] = default_guys[i];
9639
2/2
✓ Branch 0 taken 18200 times.
✓ Branch 1 taken 208 times.
18408 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9640 18408 guysbuf[i].spr_death = iwDeath;
9641 18408 guysbuf[i].spr_spawn = iwSpawn;
9642 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9643
4/4
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 17169 times.
✓ Branch 2 taken 1232 times.
✓ Branch 3 taken 7 times.
18408 if(guyversion<=3 && i==ePATRABS)
9644 {
9645 7 guysbuf[i].bosspal=spDIG;
9646 7 guysbuf[i].cset=14;
9647 7 guysbuf[i].misc9=14;
9648 7 }
9649
9650
2/2
✓ Branch 0 taken 17169 times.
✓ Branch 1 taken 1239 times.
18408 if(guyversion<=3)
9651 {
9652 // Rope/Ghini Flash rules
9653
2/2
✓ Branch 0 taken 354 times.
✓ Branch 1 taken 885 times.
1239 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9654 {
9655
2/2
✓ Branch 0 taken 880 times.
✓ Branch 1 taken 5 times.
885 if(i==eROPE2)
9656 {
9657 5 guysbuf[i].flags2 &= ~guy_flashing;
9658 5 }
9659 885 }
9660
9661
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 531 times.
1239 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9662 {
9663
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9664 {
9665 18 guysbuf[i].flags2 &= ~guy_flashing;
9666 18 }
9667 531 }
9668
9669
2/2
✓ Branch 0 taken 1232 times.
✓ Branch 1 taken 7 times.
1239 if(i==eGHINI2)
9670 {
9671
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 3 times.
7 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9672 {
9673 3 guysbuf[i].flags2 |= guy_blinking;
9674 3 }
9675
9676
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9677 {
9678 guysbuf[i].flags2 |= guy_transparent;
9679 }
9680 7 }
9681 1239 }
9682
9683 // Darknut fix
9684
10/10
✓ Branch 0 taken 18304 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 18200 times.
✓ Branch 3 taken 104 times.
✓ Branch 4 taken 18096 times.
✓ Branch 5 taken 104 times.
✓ Branch 6 taken 17992 times.
✓ Branch 7 taken 104 times.
✓ Branch 8 taken 104 times.
✓ Branch 9 taken 17888 times.
18408 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9685 {
9686
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 190 times.
520 if(get_bit(quest_rules,qr_NEWENEMYTILES))
9687 {
9688 330 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9689 330 guysbuf[i].s_width=guysbuf[i].e_width;
9690 330 guysbuf[i].s_height=guysbuf[i].e_height;
9691 330 }
9692 190 else guysbuf[i].s_tile=860;
9693
9694
2/2
✓ Branch 0 taken 485 times.
✓ Branch 1 taken 35 times.
520 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9695 {
9696 35 guysbuf[i].flags |= guy_bkshield;
9697 35 }
9698 520 }
9699
9700
4/4
✓ Branch 0 taken 18304 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 18404 times.
✓ Branch 3 taken 4 times.
18408 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9701 {
9702 4 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9703 4 }
9704 18408 }
9705 104 }
9706
9707 1792 void reset_weaponname(int32_t i)
9708 {
9709
2/2
✓ Branch 0 taken 616 times.
✓ Branch 1 taken 1176 times.
1792 if(i<wLast)
9710 {
9711 616 strcpy(weapon_string[i],old_weapon_string[i]);
9712 616 }
9713 else
9714 1176 sprintf(weapon_string[i],"zz%03d",i);
9715 1792 }
9716
9717 104 void init_item_drop_sets()
9718 {
9719
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9720 {
9721 // item_drop_sets[i] = default_item_drop_sets[0];
9722 26624 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9723 26624 }
9724
9725
2/2
✓ Branch 0 taken 1352 times.
✓ Branch 1 taken 104 times.
1456 for(int32_t i=0; i<isMAX; i++)
9726 {
9727 1352 item_drop_sets[i] = default_item_drop_sets[i];
9728
9729 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9730
2/2
✓ Branch 0 taken 13520 times.
✓ Branch 1 taken 1352 times.
14872 for(int32_t j=0; j<10; ++j)
9731 {
9732 13520 int32_t it = item_drop_sets[i].item[j];
9733
9734
3/4
✓ Branch 0 taken 9568 times.
✓ Branch 1 taken 3952 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 618 times.
13520 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9735
2/2
✓ Branch 0 taken 618 times.
✓ Branch 1 taken 8950 times.
9568 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9736 {
9737 618 item_drop_sets[i].chance[j+1]=0;
9738 618 }
9739
3/4
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 12486 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 416 times.
12902 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9740 {
9741 item_drop_sets[i].chance[j+1]=0;
9742 }
9743
9744 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9745
2/2
✓ Branch 0 taken 13512 times.
✓ Branch 1 taken 8 times.
13520 if(itemsbuf[it].family == itype_misc)
9746 {
9747 // If a non-gameplay item was selected, then item drop was aborted.
9748 // Reflect this by increasing the 'Nothing' chance accordingly.
9749 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9750 8 item_drop_sets[i].chance[j+1]=0;
9751 8 }
9752 13520 }
9753 1352 }
9754 104 }
9755
9756 102 void init_favorites()
9757 {
9758
2/2
✓ Branch 0 taken 30600 times.
✓ Branch 1 taken 102 times.
30702 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9759 {
9760 30600 favorite_combos[i]=-1;
9761 30600 }
9762
9763
2/2
✓ Branch 0 taken 30600 times.
✓ Branch 1 taken 102 times.
30702 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9764 {
9765 30600 favorite_comboaliases[i]=-1;
9766 30600 }
9767 102 }
9768
9769 const char *ctype_name[cMAX]=
9770 {
9771 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9772 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9773 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9774 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9775 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9776 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9777 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9778 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9779 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9780 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9781 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9782 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9783 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9784 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9785 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9786 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9787 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9788 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9789 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9790 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9791 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9792 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9793 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9794 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9795 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9796 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9797 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9798 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9799
9800 };
9801
9802 187 int32_t init_combo_classes()
9803 {
9804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 187 times.
187 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9805
2/2
✓ Branch 0 taken 33847 times.
✓ Branch 1 taken 187 times.
34034 for(int32_t i=0; i<cMAX; i++)
9806 {
9807 33847 combo_class_buf[i] = default_combo_classes[i];
9808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33847 times.
33847 if ( char const* nm = zi->getComboTypeName(i) )
9809 {
9810 33847 size_t len = strlen(nm);
9811
2/2
✓ Branch 0 taken 2166208 times.
✓ Branch 1 taken 33847 times.
2200055 for ( size_t q = 0; q < 64; q++ )
9812 {
9813
2/2
✓ Branch 0 taken 500225 times.
✓ Branch 1 taken 1665983 times.
2166208 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9814 2166208 }
9815 33847 }
9816 33847 }
9817
9818 187 return 0;
9819 }
9820
9821 83 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
9822 {
9823
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 assert(v_herosprites < 6);
9824 //these are here to bypass compiler warnings about unused arguments
9825 83 cv_herosprites=cv_herosprites;
9826
9827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(keepdata)
9828 {
9829 83 zinit.hero_swim_speed=67; //default
9830 83 setupherotiles(zinit.heroAnimationStyle);
9831 83 setupherodefenses();
9832 83 setupherooffsets();
9833 83 }
9834
9835
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 74 times.
83 if(v_herosprites>=0)
9836 {
9837 word tile, tile2;
9838 byte flip, extend, dummy_byte;
9839
9840
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9841 {
9842
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9843 {
9844 return qe_invalid;
9845 }
9846
9847
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9848 {
9849 return qe_invalid;
9850 }
9851
9852
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9853 {
9854 return qe_invalid;
9855 }
9856
9857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9858 {
9859 296 walkspr[i][spr_tile]=(int32_t)tile;
9860 296 walkspr[i][spr_flip]=(int32_t)flip;
9861 296 walkspr[i][spr_extend]=(int32_t)extend;
9862 296 }
9863 296 }
9864
9865
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9866 {
9867
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9868 {
9869 return qe_invalid;
9870 }
9871
9872
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9873 {
9874 return qe_invalid;
9875 }
9876
9877
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9878 {
9879 return qe_invalid;
9880 }
9881
9882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9883 {
9884 296 stabspr[i][spr_tile]=(int32_t)tile;
9885 296 stabspr[i][spr_flip]=(int32_t)flip;
9886 296 stabspr[i][spr_extend]=(int32_t)extend;
9887 296 }
9888 296 }
9889
9890
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9891 {
9892
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9893 {
9894 return qe_invalid;
9895 }
9896
9897
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9898 {
9899 return qe_invalid;
9900 }
9901
9902
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9903 {
9904 return qe_invalid;
9905 }
9906
9907
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9908 {
9909 296 slashspr[i][spr_tile]=(int32_t)tile;
9910 296 slashspr[i][spr_flip]=(int32_t)flip;
9911 296 slashspr[i][spr_extend]=(int32_t)extend;
9912 296 }
9913 296 }
9914
9915
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9916 {
9917
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9918 {
9919 return qe_invalid;
9920 }
9921
9922
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9923 {
9924 return qe_invalid;
9925 }
9926
9927
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9928 {
9929 return qe_invalid;
9930 }
9931
9932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9933 {
9934 296 floatspr[i][spr_tile]=(int32_t)tile;
9935 296 floatspr[i][spr_flip]=(int32_t)flip;
9936 296 floatspr[i][spr_extend]=(int32_t)extend;
9937 296 }
9938 296 }
9939
9940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>1)
9941 {
9942
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9943 {
9944
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9945 {
9946 return qe_invalid;
9947 }
9948
9949
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9950 {
9951 return qe_invalid;
9952 }
9953
9954
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9955 {
9956 return qe_invalid;
9957 }
9958
9959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9960 {
9961 296 swimspr[i][spr_tile]=(int32_t)tile;
9962 296 swimspr[i][spr_flip]=(int32_t)flip;
9963 296 swimspr[i][spr_extend]=(int32_t)extend;
9964 296 }
9965 296 }
9966 74 }
9967
9968
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9969 {
9970
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9971 {
9972 return qe_invalid;
9973 }
9974
9975
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
9976 {
9977 return qe_invalid;
9978 }
9979
9980
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
9981 {
9982 return qe_invalid;
9983 }
9984
9985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
9986 {
9987 296 divespr[i][spr_tile]=(int32_t)tile;
9988 296 divespr[i][spr_flip]=(int32_t)flip;
9989 296 divespr[i][spr_extend]=(int32_t)extend;
9990 296 }
9991 296 }
9992
9993
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
9994 {
9995
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
9996 {
9997 return qe_invalid;
9998 }
9999
10000
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10001 {
10002 return qe_invalid;
10003 }
10004
10005
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10006 {
10007 return qe_invalid;
10008 }
10009
10010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10011 {
10012 296 poundspr[i][spr_tile]=(int32_t)tile;
10013 296 poundspr[i][spr_flip]=(int32_t)flip;
10014 296 poundspr[i][spr_extend]=(int32_t)extend;
10015 296 }
10016 296 }
10017
10018
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_igetw(&tile,f,keepdata))
10019 {
10020 return qe_invalid;
10021 }
10022
10023 74 flip=0;
10024
10025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>0)
10026 {
10027
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&flip,f,keepdata))
10028 {
10029 return qe_invalid;
10030 }
10031 74 }
10032
10033
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(!p_getc(&extend,f,keepdata))
10034 {
10035 return qe_invalid;
10036 }
10037
10038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10039 {
10040 74 castingspr[spr_tile]=(int32_t)tile;
10041 74 castingspr[spr_flip]=(int32_t)flip;
10042 74 castingspr[spr_extend]=(int32_t)extend;
10043 74 }
10044
10045
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(v_herosprites>0)
10046 {
10047 74 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10048
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 74 times.
222 for(int32_t i=0; i<2; i++)
10049 {
10050
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 148 times.
444 for(int32_t j=0; j<num_holdsprs; j++)
10051 {
10052
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10053 {
10054 return qe_invalid;
10055 }
10056
10057
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10068 {
10069 296 holdspr[i][j][spr_tile]=(int32_t)tile;
10070 296 holdspr[i][j][spr_flip]=(int32_t)flip;
10071 296 holdspr[i][j][spr_extend]=(int32_t)extend;
10072 296 }
10073 296 }
10074 148 }
10075 74 }
10076 else
10077 {
10078 for(int32_t i=0; i<2; i++)
10079 {
10080 if(!p_igetw(&tile,f,keepdata))
10081 {
10082 return qe_invalid;
10083 }
10084
10085 if(!p_igetw(&tile2,f,keepdata))
10086 {
10087 return qe_invalid;
10088 }
10089
10090 if(!p_getc(&extend,f,keepdata))
10091 {
10092 return qe_invalid;
10093 }
10094
10095 if(keepdata)
10096 {
10097 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10098 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10099 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10100 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10101 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10102 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10103 }
10104 }
10105 }
10106
10107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>2)
10108 {
10109
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10110 {
10111
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10112 {
10113 return qe_invalid;
10114 }
10115
10116
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10117 {
10118 return qe_invalid;
10119 }
10120
10121
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10122 {
10123 return qe_invalid;
10124 }
10125
10126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10127 {
10128 296 jumpspr[i][spr_tile]=(int32_t)tile;
10129 296 jumpspr[i][spr_flip]=(int32_t)flip;
10130 296 jumpspr[i][spr_extend]=(int32_t)extend;
10131 296 }
10132 296 }
10133 74 }
10134
10135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>3)
10136 {
10137
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i=0; i<4; i++)
10138 {
10139
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_igetw(&tile,f,keepdata))
10140 {
10141 return qe_invalid;
10142 }
10143
10144
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&flip,f,keepdata))
10145 {
10146 return qe_invalid;
10147 }
10148
10149
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&extend,f,keepdata))
10150 {
10151 return qe_invalid;
10152 }
10153
10154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 296 times.
296 if(keepdata)
10155 {
10156 296 chargespr[i][spr_tile]=(int32_t)tile;
10157 296 chargespr[i][spr_flip]=(int32_t)flip;
10158 296 chargespr[i][spr_extend]=(int32_t)extend;
10159 296 }
10160 296 }
10161 74 }
10162
10163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(v_herosprites>4)
10164 {
10165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(!p_getc(&dummy_byte,f,keepdata))
10166 {
10167 return qe_invalid;
10168 }
10169
10170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(keepdata)
10171 {
10172 74 zinit.hero_swim_speed=(byte)dummy_byte;
10173 74 }
10174 74 }
10175
10176
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(keepdata)
10177 {
10178 74 memset(frozenspr, 0, sizeof(frozenspr));
10179 74 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10180 74 memset(onfirespr, 0, sizeof(onfirespr));
10181 74 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10182 74 memset(diggingspr, 0, sizeof(diggingspr));
10183 74 memset(usingrodspr, 0, sizeof(usingrodspr));
10184 74 memset(usingcanespr, 0, sizeof(usingcanespr));
10185 74 memset(pushingspr, 0, sizeof(pushingspr));
10186 74 memset(liftingspr, 0, sizeof(liftingspr));
10187 74 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10188 74 memset(stunnedspr, 0, sizeof(stunnedspr));
10189 74 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10190 74 memset(fallingspr, 0, sizeof(fallingspr));
10191 74 memset(shockedspr, 0, sizeof(shockedspr));
10192 74 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10193 74 memset(pullswordspr, 0, sizeof(pullswordspr));
10194 74 memset(readingspr, 0, sizeof(readingspr));
10195 74 memset(slash180spr, 0, sizeof(slash180spr));
10196 74 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10197 74 memset(dashspr, 0, sizeof(dashspr));
10198 74 memset(bonkspr, 0, sizeof(bonkspr));
10199 74 memset(medallionsprs, 0, sizeof(medallionsprs));
10200 74 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10201 74 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10202
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t q = 0; q < 4; ++q)
10203 {
10204
2/2
✓ Branch 0 taken 888 times.
✓ Branch 1 taken 296 times.
1184 for(int32_t p = 0; p < 3; ++p)
10205 {
10206 888 drowningspr[q][p] = divespr[q][p];
10207 888 drowning_lavaspr[q][p] = divespr[q][p];
10208 888 }
10209 296 }
10210 74 memset(sideswimspr, 0, sizeof(sideswimspr));
10211 74 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10212 74 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10213 74 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10214 74 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10215 74 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10216 74 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10217 74 }
10218 74 }
10219
10220 83 return 0;
10221 83 }
10222
10223 3910 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10224 {
10225 3910 arr[spr_tile] = tile;
10226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3910 times.
3910 arr[spr_flip] = (flip > 3 ? 0 : flip);
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3910 times.
3910 arr[spr_extend] = (ext > 2 ? 0 : ext);
10228 3910 }
10229 //Used to read the player sprites as int32_t, not word.
10230 23 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites, bool keepdata)
10231 {
10232 //these are here to bypass compiler warnings about unused arguments
10233 23 cv_herosprites=cv_herosprites;
10234
10235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10236 {
10237 23 zinit.hero_swim_speed=67; //default
10238 23 setupherotiles(zinit.heroAnimationStyle);
10239 23 setupherodefenses();
10240 23 setupherooffsets();
10241 23 }
10242
10243 int32_t tile, tile2;
10244 byte flip, extend, dummy_byte;
10245
10246
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>=0)
10247 {
10248
10249
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10250 {
10251
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10252 {
10253 return qe_invalid;
10254 }
10255
10256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10257 {
10258 return qe_invalid;
10259 }
10260
10261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10262 {
10263 return qe_invalid;
10264 }
10265
10266 92 if(keepdata)
10267 {
10268 92 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10269 92 }
10270 92 }
10271
10272
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10273 {
10274
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10275 {
10276 return qe_invalid;
10277 }
10278
10279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10280 {
10281 return qe_invalid;
10282 }
10283
10284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10285 {
10286 return qe_invalid;
10287 }
10288
10289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10290 {
10291 92 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10292 92 }
10293 92 }
10294
10295
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10296 {
10297
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10298 {
10299 return qe_invalid;
10300 }
10301
10302
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10303 {
10304 return qe_invalid;
10305 }
10306
10307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10308 {
10309 return qe_invalid;
10310 }
10311
10312
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10313 {
10314 92 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10315 92 }
10316 92 }
10317
10318
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10319 {
10320
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10321 {
10322 return qe_invalid;
10323 }
10324
10325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10326 {
10327 return qe_invalid;
10328 }
10329
10330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10331 {
10332 return qe_invalid;
10333 }
10334
10335
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10336 {
10337 92 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10338 92 }
10339 92 }
10340
10341
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>1)
10342 {
10343
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10344 {
10345
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10346 {
10347 return qe_invalid;
10348 }
10349
10350
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10351 {
10352 return qe_invalid;
10353 }
10354
10355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10356 {
10357 return qe_invalid;
10358 }
10359
10360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10361 {
10362 92 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10363 92 }
10364 92 }
10365 23 }
10366
10367
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10368 {
10369
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10370 {
10371 return qe_invalid;
10372 }
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10375 {
10376 return qe_invalid;
10377 }
10378
10379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10380 {
10381 return qe_invalid;
10382 }
10383
10384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10385 {
10386 92 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10387 92 }
10388 92 }
10389
10390
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10391 {
10392
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10393 {
10394 return qe_invalid;
10395 }
10396
10397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10398 {
10399 return qe_invalid;
10400 }
10401
10402
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10403 {
10404 return qe_invalid;
10405 }
10406
10407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10408 {
10409 92 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10410 92 }
10411 92 }
10412
10413
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tile,f,keepdata))
10414 {
10415 return qe_invalid;
10416 }
10417
10418 23 flip=0;
10419
10420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>0)
10421 {
10422
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&flip,f,keepdata))
10423 {
10424 return qe_invalid;
10425 }
10426 23 }
10427
10428
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&extend,f,keepdata))
10429 {
10430 return qe_invalid;
10431 }
10432
10433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10434 {
10435 23 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10436 23 }
10437
10438
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(v_herosprites>0)
10439 {
10440 23 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10441
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for(int32_t i=0; i<2; i++)
10442 {
10443
2/2
✓ Branch 0 taken 138 times.
✓ Branch 1 taken 46 times.
184 for(int32_t j=0; j<num_holdsprs; j++)
10444 {
10445
1/2
✓ Branch 0 taken 138 times.
✗ Branch 1 not taken.
138 if(!p_igetl(&tile,f,keepdata))
10446 {
10447 return qe_invalid;
10448 }
10449
10450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!p_getc(&flip,f,keepdata))
10451 {
10452 return qe_invalid;
10453 }
10454
10455
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(!p_getc(&extend,f,keepdata))
10456 {
10457 return qe_invalid;
10458 }
10459
10460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 138 times.
138 if(keepdata)
10461 {
10462 138 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10463 138 }
10464 138 }
10465 46 }
10466 23 }
10467 else
10468 {
10469 for(int32_t i=0; i<2; i++)
10470 {
10471 if(!p_igetl(&tile,f,keepdata))
10472 {
10473 return qe_invalid;
10474 }
10475
10476 if(!p_igetl(&tile2,f,keepdata))
10477 {
10478 return qe_invalid;
10479 }
10480
10481 if(!p_getc(&extend,f,keepdata))
10482 {
10483 return qe_invalid;
10484 }
10485
10486 if(keepdata)
10487 {
10488 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10489 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10490 }
10491 }
10492 }
10493
10494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>2)
10495 {
10496
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10497 {
10498
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10499 {
10500 return qe_invalid;
10501 }
10502
10503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10504 {
10505 return qe_invalid;
10506 }
10507
10508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10514 {
10515 92 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10516 92 }
10517 92 }
10518 23 }
10519
10520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>3)
10521 {
10522
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t i=0; i<4; i++)
10523 {
10524
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10525 {
10526 return qe_invalid;
10527 }
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10530 {
10531 return qe_invalid;
10532 }
10533
10534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10535 {
10536 return qe_invalid;
10537 }
10538
10539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10540 {
10541 92 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10542 92 }
10543 92 }
10544 23 }
10545
10546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(v_herosprites>4)
10547 {
10548
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&dummy_byte,f,keepdata))
10549 {
10550 return qe_invalid;
10551 }
10552
10553
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(keepdata)
10554 {
10555 23 zinit.hero_swim_speed=(byte)dummy_byte;
10556 23 }
10557 23 }
10558
10559
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(v_herosprites>6)
10560 {
10561
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10562 {
10563
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10564 return qe_invalid;
10565
10566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10567 return qe_invalid;
10568
10569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10570 return qe_invalid;
10571
10572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10573 {
10574 92 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10575 92 }
10576 92 }
10577
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10578 {
10579
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10580 return qe_invalid;
10581
10582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10583 return qe_invalid;
10584
10585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10586 return qe_invalid;
10587
10588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10589 {
10590 92 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10591 92 }
10592 92 }
10593
10594
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10595 {
10596
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10597 return qe_invalid;
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10600 return qe_invalid;
10601
10602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10603 return qe_invalid;
10604
10605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10606 {
10607 92 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10608 92 }
10609 92 }
10610
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10611 {
10612
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10613 return qe_invalid;
10614
10615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10616 return qe_invalid;
10617
10618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10619 return qe_invalid;
10620
10621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10622 {
10623 92 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10624 92 }
10625 92 }
10626
10627
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10628 {
10629
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10630 return qe_invalid;
10631
10632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10633 return qe_invalid;
10634
10635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10636 return qe_invalid;
10637
10638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10639 {
10640 92 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10641 92 }
10642 92 }
10643
10644
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10645 {
10646
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10647 return qe_invalid;
10648
10649
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10650 return qe_invalid;
10651
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10653 return qe_invalid;
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10656 {
10657 92 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10658 92 }
10659 92 }
10660
10661
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10662 {
10663
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10664 return qe_invalid;
10665
10666
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10667 return qe_invalid;
10668
10669
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10670 return qe_invalid;
10671
10672
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10673 {
10674 92 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10675 92 }
10676 92 }
10677
10678
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10679 {
10680
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10681 return qe_invalid;
10682
10683
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10684 return qe_invalid;
10685
10686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10687 return qe_invalid;
10688
10689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10690 {
10691 92 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10692 92 }
10693 92 }
10694
10695
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10696 {
10697
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10698 return qe_invalid;
10699
10700
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10701 return qe_invalid;
10702
10703
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10704 return qe_invalid;
10705
10706 92 byte frames = 0;
10707
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 84 times.
92 if(v_herosprites > 15)
10708 {
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
84 if(!p_getc(&frames,f,keepdata))
10710 return qe_invalid;
10711 84 }
10712
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10714 {
10715 92 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10716 92 liftingspr[q][spr_frames] = frames;
10717 92 }
10718 92 }
10719
10720
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10721 {
10722
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10723 return qe_invalid;
10724
10725
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10726 return qe_invalid;
10727
10728
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10729 return qe_invalid;
10730
10731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10732 {
10733 92 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10734 92 }
10735 92 }
10736
10737
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10738 {
10739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&tile,f,keepdata))
10740 return qe_invalid;
10741
10742
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10743 return qe_invalid;
10744
10745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10746 return qe_invalid;
10747
10748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10749 {
10750 92 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10751 92 }
10752 92 }
10753
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10754 {
10755
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10756 return qe_invalid;
10757
10758
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10759 return qe_invalid;
10760
10761
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10762 return qe_invalid;
10763
10764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10765 {
10766 92 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10767 92 }
10768 92 }
10769
10770
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10771 {
10772
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10773 return qe_invalid;
10774
10775
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10776 return qe_invalid;
10777
10778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10779 return qe_invalid;
10780
10781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10782 {
10783 92 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10784 92 }
10785 92 }
10786
10787
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10788 {
10789
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10790 return qe_invalid;
10791
10792
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10793 return qe_invalid;
10794
10795
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10796 return qe_invalid;
10797
10798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10799 {
10800 92 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10801 92 }
10802 92 }
10803
10804
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10805 {
10806
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10807 return qe_invalid;
10808
10809
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10810 return qe_invalid;
10811
10812
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10813 return qe_invalid;
10814
10815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10816 {
10817 92 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10818 92 }
10819 92 }
10820
10821
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10822 {
10823
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10824 return qe_invalid;
10825
10826
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10827 return qe_invalid;
10828
10829
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10830 return qe_invalid;
10831
10832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10833 {
10834 92 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10835 92 }
10836 92 }
10837
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10840 return qe_invalid;
10841
10842
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10843 return qe_invalid;
10844
10845
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10846 return qe_invalid;
10847
10848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10849 {
10850 92 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10851 92 }
10852 92 }
10853
10854
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10855 {
10856
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10857 return qe_invalid;
10858
10859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
10860 return qe_invalid;
10861
10862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10863 return qe_invalid;
10864
10865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10866 {
10867 92 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10868 92 }
10869 92 }
10870
10871
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10872 {
10873
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10874 return qe_invalid;
10875
10876
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10877 return qe_invalid;
10878
10879
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10880 return qe_invalid;
10881
10882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10883 {
10884 92 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10885 92 }
10886 92 }
10887
10888
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10889 {
10890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&tile,f,keepdata))
10891 return qe_invalid;
10892
10893
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10894 return qe_invalid;
10895
10896
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
10897 return qe_invalid;
10898
10899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10900 {
10901 92 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10902 92 }
10903 92 }
10904
10905
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10906 {
10907
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10908 return qe_invalid;
10909
10910
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10911 return qe_invalid;
10912
10913
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10914 return qe_invalid;
10915
10916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10917 {
10918 92 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10919 92 }
10920 92 }
10921
10922
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10923 {
10924
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10925 return qe_invalid;
10926
10927
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10928 return qe_invalid;
10929
10930
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10931 return qe_invalid;
10932
10933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10934 {
10935 92 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10936 92 }
10937 92 }
10938
10939
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
10940 {
10941
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
10942 return qe_invalid;
10943
10944
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&flip,f,keepdata))
10945 return qe_invalid;
10946
10947
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&extend,f,keepdata))
10948 return qe_invalid;
10949
10950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
10951 {
10952 92 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10953 92 }
10954 92 }
10955
10956
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10957 {
10958
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetl(&tile,f,keepdata))
10959 return qe_invalid;
10960
10961
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_getc(&flip,f,keepdata))
10962 return qe_invalid;
10963
10964
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_getc(&extend,f,keepdata))
10965 return qe_invalid;
10966
10967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(keepdata)
10968 {
10969 69 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10970 69 }
10971 69 }
10972 23 }
10973 else if(keepdata)
10974 {
10975 memset(frozenspr, 0, sizeof(frozenspr));
10976 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10977 memset(onfirespr, 0, sizeof(onfirespr));
10978 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10979 memset(diggingspr, 0, sizeof(diggingspr));
10980 memset(usingrodspr, 0, sizeof(usingrodspr));
10981 memset(usingcanespr, 0, sizeof(usingcanespr));
10982 memset(pushingspr, 0, sizeof(pushingspr));
10983 memset(liftingspr, 0, sizeof(liftingspr));
10984 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10985 memset(stunnedspr, 0, sizeof(stunnedspr));
10986 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10987 memset(fallingspr, 0, sizeof(fallingspr));
10988 memset(shockedspr, 0, sizeof(shockedspr));
10989 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10990 memset(pullswordspr, 0, sizeof(pullswordspr));
10991 memset(readingspr, 0, sizeof(readingspr));
10992 memset(slash180spr, 0, sizeof(slash180spr));
10993 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10994 memset(dashspr, 0, sizeof(dashspr));
10995 memset(bonkspr, 0, sizeof(bonkspr));
10996 memset(medallionsprs, 0, sizeof(medallionsprs));
10997 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10998 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10999 for(int32_t q = 0; q < 4; ++q)
11000 {
11001 for(int32_t p = 0; p < 3; ++p)
11002 {
11003 drowningspr[q][p] = divespr[q][p];
11004 drowning_lavaspr[q][p] = divespr[q][p];
11005 }
11006 }
11007 }
11008
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 8)
11009 {
11010
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11011 {
11012
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11013 return qe_invalid;
11014
11015
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11016 return qe_invalid;
11017
11018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11019 return qe_invalid;
11020
11021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11022 {
11023 92 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11024 92 }
11025 92 }
11026 23 }
11027 else if (keepdata)
11028 {
11029 memset(sideswimspr, 0, sizeof(sideswimspr));
11030 }
11031
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 9)
11032 {
11033
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11034 {
11035
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11039 return qe_invalid;
11040
11041
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11042 return qe_invalid;
11043
11044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11045 {
11046 92 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11047 92 }
11048 92 }
11049
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11050 {
11051
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11052 return qe_invalid;
11053
11054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11055 return qe_invalid;
11056
11057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11058 return qe_invalid;
11059
11060
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11061 {
11062 92 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11063 92 }
11064 92 }
11065
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11066 {
11067
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11068 return qe_invalid;
11069
11070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11071 return qe_invalid;
11072
11073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11074 return qe_invalid;
11075
11076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11077 {
11078 92 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11079 92 }
11080 92 }
11081
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11082 {
11083
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11084 return qe_invalid;
11085
11086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11087 return qe_invalid;
11088
11089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11090 return qe_invalid;
11091
11092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11093 {
11094 92 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11095 92 }
11096 92 }
11097 23 }
11098 else if (keepdata)
11099 {
11100 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11101 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11102 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11103 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11104 }
11105
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 10)
11106 {
11107
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11108 {
11109 int32_t hmr;
11110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_igetl(&hmr,f,keepdata))
11111 return qe_invalid;
11112
11113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11114 {
11115 92 hammeroffsets[q] = hmr;
11116 92 }
11117 92 }
11118 23 }
11119 else if (keepdata)
11120 {
11121 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11122 }
11123
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 11)
11124 {
11125
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 23 times.
92 for(int32_t q = 0; q < 3; ++q)
11126 {
11127
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetl(&tile,f,keepdata))
11128 return qe_invalid;
11129
11130
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&flip,f,keepdata))
11131 return qe_invalid;
11132
11133
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&extend,f,keepdata))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(keepdata)
11137 {
11138 69 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11139 69 }
11140 69 }
11141 23 }
11142 else if (keepdata)
11143 {
11144 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11145 }
11146
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 12)
11147 {
11148
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tile,f,keepdata))
11149 return qe_invalid;
11150
11151
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&flip,f,keepdata))
11152 return qe_invalid;
11153
11154
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_getc(&extend,f,keepdata))
11155 return qe_invalid;
11156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if (keepdata)
11157 {
11158 23 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11159 23 }
11160
11161 23 }
11162 else if (keepdata)
11163 {
11164 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11165 }
11166
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 13)
11167 {
11168
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11169 {
11170
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11171 return qe_invalid;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11174 return qe_invalid;
11175
11176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11177 return qe_invalid;
11178
11179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11180 {
11181 92 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11182 92 }
11183 92 }
11184 23 }
11185 else if (keepdata)
11186 {
11187 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11188 }
11189
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 14)
11190 {
11191
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23 times.
115 for(int32_t q = 0; q < 4; ++q)
11192 {
11193
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetl(&tile,f,keepdata))
11194 return qe_invalid;
11195
11196
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&flip,f,keepdata))
11197 return qe_invalid;
11198
11199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(!p_getc(&extend,f,keepdata))
11200 return qe_invalid;
11201
11202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if(keepdata)
11203 {
11204 92 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11205 92 }
11206 92 }
11207 23 }
11208 else if (keepdata)
11209 {
11210 memset(revslashspr, 0, sizeof(revslashspr));
11211 }
11212
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if (v_herosprites > 7)
11213 {
11214 23 int32_t num_defense = wMax;
11215 23 byte def = 0;
11216
11217 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11218 /*if(v_herosprites > [x])
11219 * {
11220 * num_defense = 146 //value of wMax on version 8
11221 * }
11222 */
11223
11224
2/2
✓ Branch 0 taken 3358 times.
✓ Branch 1 taken 23 times.
3381 for (int32_t q = 0; q < num_defense; q++)
11225 {
11226
1/2
✓ Branch 0 taken 3358 times.
✗ Branch 1 not taken.
3358 if (!p_getc(&def, f, keepdata))
11227 return qe_invalid;
11228
11229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3358 times.
3358 if (keepdata)
11230 {
11231 3358 hero_defence[q] = def;
11232 3358 }
11233 3358 }
11234 23 }
11235 else if (keepdata)
11236 {
11237 int32_t num_defense = wMax;
11238 for (int32_t q = 0; q < num_defense; q++)
11239 {
11240 hero_defence[q] = 0;
11241 }
11242 }
11243 23 }
11244
11245 23 return 0;
11246 23 }
11247
11248
11249 97 int32_t readherosprites(PACKFILE *f, zquestheader *Header, bool keepdata)
11250 {
11251 //these are here to bypass compiler warnings about unused arguments
11252 97 Header=Header;
11253
11254 dword dummy;
11255 97 word s_version=0, s_cversion=0;
11256
11257 //section version info
11258
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
11259 {
11260 return qe_invalid;
11261 }
11262
11263 97 FFCore.quest_format[vHeroSprites] = s_version;
11264
11265 //al_trace("Player sprites version %d\n", s_version);
11266
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
11267 {
11268 return qe_invalid;
11269 }
11270
11271 //section size
11272
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy,f,true))
11273 {
11274 return qe_invalid;
11275 }
11276
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if ( s_version >= 6 )
11277 {
11278 //al_trace("Reading Player Sprites v6\n");
11279 23 return readherosprites3(f, s_version, dummy, keepdata);
11280 }
11281 74 else return readherosprites2(f, s_version, dummy, keepdata);
11282 97 }
11283
11284 97 int32_t readsubscreens(PACKFILE *f, zquestheader *Header, bool keepdata)
11285 {
11286 int32_t dummy;
11287 97 word s_version=0, s_cversion=0;
11288
11289 //section version info
11290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
11291 {
11292 return qe_invalid;
11293 }
11294
11295 97 FFCore.quest_format[vSubscreen] = s_version;
11296
11297 //al_trace("Subscreens version %d\n", s_version);
11298
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
11299 {
11300 return qe_invalid;
11301 }
11302
11303 //section size
11304
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy,f,true))
11305 {
11306 return qe_invalid;
11307 }
11308
11309 //finally... section data
11310
2/2
✓ Branch 0 taken 12416 times.
✓ Branch 1 taken 97 times.
12513 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11311 {
11312 12416 int32_t ret = read_one_subscreen(f, Header, keepdata, i, s_version, s_cversion);
11313
11314
1/2
✓ Branch 0 taken 12416 times.
✗ Branch 1 not taken.
12416 if(ret!=0) return ret;
11315 12416 }
11316
11317 97 return 0;
11318 97 }
11319
11320 12416 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, bool keepdata, int32_t i, word s_version, word)
11321 {
11322 12416 int32_t numsub=0;
11323 12416 byte temp_ss=0;
11324 subscreen_object temp_sub_stack;
11325 12416 subscreen_object *temp_sub = &temp_sub_stack;
11326
11327 char tempname[64];
11328
11329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12416 times.
12416 if(!pfread(tempname,64,f,true))
11330 {
11331 return qe_invalid;
11332 }
11333
11334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12416 times.
12416 if(s_version > 1)
11335 {
11336
1/2
✓ Branch 0 taken 12416 times.
✗ Branch 1 not taken.
12416 if(!p_getc(&temp_ss,f,keepdata))
11337 {
11338 return qe_invalid;
11339 }
11340 12416 }
11341
11342
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12416 times.
12416 if(s_version < 4)
11343 {
11344 uint8_t tmp=0;
11345
11346 if(!p_getc(&tmp,f,true))
11347 {
11348 return qe_invalid;
11349 }
11350
11351 numsub = (int32_t)tmp;
11352 }
11353 else
11354 {
11355 word tmp;
11356
11357
1/2
✓ Branch 0 taken 12416 times.
✗ Branch 1 not taken.
12416 if(!p_igetw(&tmp, f, true))
11358 {
11359 return qe_invalid;
11360 }
11361
11362 12416 numsub = (int32_t)tmp;
11363 }
11364
11365 int32_t j;
11366
11367
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 32677 times.
✓ Branch 2 taken 20261 times.
✓ Branch 3 taken 12416 times.
32677 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11368 {
11369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20261 times.
20261 if(keepdata)
11370 {
11371 20261 memset(temp_sub,0,sizeof(subscreen_object));
11372
11373
2/2
✓ Branch 0 taken 1158 times.
✓ Branch 1 taken 19103 times.
20261 switch(custom_subscreen[i].objects[j].type)
11374 {
11375 case ssoTEXT:
11376 case ssoTEXTBOX:
11377 case ssoCURRENTITEMTEXT:
11378 case ssoCURRENTITEMCLASSTEXT:
11379
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1158 times.
✓ Branch 2 taken 1158 times.
✗ Branch 3 not taken.
1158 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11380
11381 //fall through
11382 default:
11383 20261 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11384 20261 break;
11385 }
11386 20261 }
11387
11388
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->type),f,true))
11389 {
11390 return qe_invalid;
11391 }
11392
11393
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->pos),f,keepdata))
11394 {
11395 return qe_invalid;
11396 }
11397
11398
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(s_version < 5)
11399 {
11400 switch(temp_sub->pos)
11401 {
11402 case 0:
11403 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11404 break;
11405
11406 case 1:
11407 temp_sub->pos = sspUP;
11408 break;
11409
11410 case 2:
11411 temp_sub->pos = sspDOWN;
11412 break;
11413
11414 default:
11415 temp_sub->pos = 0;
11416 }
11417 }
11418
11419
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->x),f,keepdata))
11420 {
11421 return qe_invalid;
11422 }
11423
11424
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->y),f,keepdata))
11425 {
11426 return qe_invalid;
11427 }
11428
11429
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->w),f,keepdata))
11430 {
11431 return qe_invalid;
11432 }
11433
11434
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->h),f,keepdata))
11435 {
11436 return qe_invalid;
11437 }
11438
11439
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->colortype1),f,keepdata))
11440 {
11441 return qe_invalid;
11442 }
11443
11444
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->color1),f,keepdata))
11445 {
11446 return qe_invalid;
11447 }
11448
11449
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->colortype2),f,keepdata))
11450 {
11451 return qe_invalid;
11452 }
11453
11454
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->color2),f,keepdata))
11455 {
11456 return qe_invalid;
11457 }
11458
11459
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->colortype3),f,keepdata))
11460 {
11461 return qe_invalid;
11462 }
11463
11464
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->color3),f,keepdata))
11465 {
11466 return qe_invalid;
11467 }
11468
11469
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d1),f,keepdata))
11470 {
11471 return qe_invalid;
11472 }
11473
11474
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d2),f,keepdata))
11475 {
11476 return qe_invalid;
11477 }
11478
11479
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d3),f,keepdata))
11480 {
11481 return qe_invalid;
11482 }
11483
11484
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d4),f,keepdata))
11485 {
11486 return qe_invalid;
11487 }
11488
11489
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d5),f,keepdata))
11490 {
11491 return qe_invalid;
11492 }
11493
11494
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d6),f,keepdata))
11495 {
11496 return qe_invalid;
11497 }
11498
11499
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d7),f,keepdata))
11500 {
11501 return qe_invalid;
11502 }
11503
11504
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d8),f,keepdata))
11505 {
11506 return qe_invalid;
11507 }
11508
11509
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d9),f,keepdata))
11510 {
11511 return qe_invalid;
11512 }
11513
11514
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetd(&(temp_sub->d10),f,keepdata))
11515 {
11516 return qe_invalid;
11517 }
11518
11519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20261 times.
20261 if(s_version < 2)
11520 {
11521 if(!p_igetl(&(temp_sub->speed),f,keepdata))
11522 {
11523 return qe_invalid;
11524 }
11525
11526 if(!p_igetl(&(temp_sub->delay),f,keepdata))
11527 {
11528 return qe_invalid;
11529 }
11530
11531 if(!p_igetl(&(temp_sub->frame),f,keepdata))
11532 {
11533 return qe_invalid;
11534 }
11535 }
11536 else
11537 {
11538
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->speed),f,keepdata))
11539 {
11540 return qe_invalid;
11541 }
11542
11543
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_getc(&(temp_sub->delay),f,keepdata))
11544 {
11545 return qe_invalid;
11546 }
11547
11548
1/2
✓ Branch 0 taken 20261 times.
✗ Branch 1 not taken.
20261 if(!p_igetw(&(temp_sub->frame),f,keepdata))
11549 {
11550 return qe_invalid;
11551 }
11552 }
11553
11554 20261 int32_t temp_size=0;
11555
11556 // bool deletets = false;
11557
4/4
✓ Branch 0 taken 8595 times.
✓ Branch 1 taken 1629 times.
✓ Branch 2 taken 9894 times.
✓ Branch 3 taken 143 times.
20261 switch(temp_sub->type)
11558 {
11559 case ssoTEXT:
11560 case ssoTEXTBOX:
11561 case ssoCURRENTITEMTEXT:
11562 case ssoCURRENTITEMCLASSTEXT:
11563 word temptempsize;
11564 /*uint8_t temp1;
11565 uint8_t temp2;
11566 temp2 = 0;
11567 if(!p_getc(&temp1,f,true))
11568 {
11569 return qe_invalid;
11570 }
11571 if(temp1)
11572 {
11573
11574 if(!p_getc(&temp2,f,true))
11575 {
11576 return qe_invalid;
11577 }
11578 }*/
11579
11580
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!p_igetw(&temptempsize,f,true))
11581 {
11582 return qe_invalid;
11583 }
11584
11585 //temptempsize = temp1 + (temp2 << 8);
11586 1629 temp_size = (int32_t)temptempsize;
11587
11588 //if(temp_sub->dp1!=NULL) delete[] temp_sub->dp1;
11589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(keepdata)
11590 {
11591 1629 uint32_t char_length = temp_size+1;
11592 1629 temp_sub->dp1 = new char[char_length]; //memory not freed
11593
11594 //deletets = true; //obsolete
11595 1629 }
11596
11597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1629 times.
1629 if(temp_size)
11598 {
11599
1/2
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
1629 if(!pfread(temp_sub->dp1,temp_size+1,f,keepdata))
11600 {
11601 return qe_invalid;
11602 }
11603 1629 }
11604
11605 1629 break;
11606
11607 case ssoLIFEMETER:
11608
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11609 temp_sub->d3 = 1;
11610
11611
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11612 {
11613 return qe_invalid;
11614 }
11615
11616 143 break;
11617
11618
11619 case ssoCURRENTITEM:
11620
11621
1/2
✓ Branch 0 taken 8595 times.
✗ Branch 1 not taken.
8595 if(s_version < 6)
11622 {
11623 switch(temp_sub->d1)
11624 {
11625 case ssiBOMB:
11626 temp_sub->d1 = itype_bomb;
11627 break;
11628
11629 case ssiSWORD:
11630 temp_sub->d1 = itype_sword;
11631 break;
11632
11633 case ssiSHIELD:
11634 temp_sub->d1 = itype_shield;
11635 break;
11636
11637 case ssiCANDLE:
11638 temp_sub->d1 = itype_candle;
11639 break;
11640
11641 case ssiLETTER:
11642 temp_sub->d1 = itype_letter;
11643 break;
11644
11645 case ssiPOTION:
11646 temp_sub->d1 = itype_potion;
11647 break;
11648
11649 case ssiLETTERPOTION:
11650 temp_sub->d1 = itype_letterpotion;
11651 break;
11652
11653 case ssiBOW:
11654 temp_sub->d1 = itype_bow;
11655 break;
11656
11657 case ssiARROW:
11658 temp_sub->d1 = itype_arrow;
11659 break;
11660
11661 case ssiBOWANDARROW:
11662 temp_sub->d1 = itype_bowandarrow;
11663 break;
11664
11665 case ssiBAIT:
11666 temp_sub->d1 = itype_bait;
11667 break;
11668
11669 case ssiRING:
11670 temp_sub->d1 = itype_ring;
11671 break;
11672
11673 case ssiBRACELET:
11674 temp_sub->d1 = itype_bracelet;
11675 break;
11676
11677 case ssiMAP:
11678 temp_sub->d1 = itype_map;
11679 break;
11680
11681 case ssiCOMPASS:
11682 temp_sub->d1 = itype_compass;
11683 break;
11684
11685 case ssiBOSSKEY:
11686 temp_sub->d1 = itype_bosskey;
11687 break;
11688
11689 case ssiMAGICKEY:
11690 temp_sub->d1 = itype_magickey;
11691 break;
11692
11693 case ssiBRANG:
11694 temp_sub->d1 = itype_brang;
11695 break;
11696
11697 case ssiWAND:
11698 temp_sub->d1 = itype_wand;
11699 break;
11700
11701 case ssiRAFT:
11702 temp_sub->d1 = itype_raft;
11703 break;
11704
11705 case ssiLADDER:
11706 temp_sub->d1 = itype_ladder;
11707 break;
11708
11709 case ssiWHISTLE:
11710 temp_sub->d1 = itype_whistle;
11711 break;
11712
11713 case ssiBOOK:
11714 temp_sub->d1 = itype_book;
11715 break;
11716
11717 case ssiWALLET:
11718 temp_sub->d1 = itype_wallet;
11719 break;
11720
11721 case ssiSBOMB:
11722 temp_sub->d1 = itype_sbomb;
11723 break;
11724
11725 case ssiHCPIECE:
11726 temp_sub->d1 = itype_heartpiece;
11727 break;
11728
11729 case ssiAMULET:
11730 temp_sub->d1 = itype_amulet;
11731 break;
11732
11733 case ssiFLIPPERS:
11734 temp_sub->d1 = itype_flippers;
11735 break;
11736
11737 case ssiHOOKSHOT:
11738 temp_sub->d1 = itype_hookshot;
11739 break;
11740
11741 case ssiLENS:
11742 temp_sub->d1 = itype_lens;
11743 break;
11744
11745 case ssiHAMMER:
11746 temp_sub->d1 = itype_hammer;
11747 break;
11748
11749 case ssiBOOTS:
11750 temp_sub->d1 = itype_boots;
11751 break;
11752
11753 case ssiDIVINEFIRE:
11754 temp_sub->d1 = itype_divinefire;
11755 break;
11756
11757 case ssiDIVINEESCAPE:
11758 temp_sub->d1 = itype_divineescape;
11759 break;
11760
11761 case ssiDIVINEPROTECTION:
11762 temp_sub->d1 = itype_divineprotection;
11763 break;
11764
11765 case ssiQUIVER:
11766 temp_sub->d1 = itype_quiver;
11767 break;
11768
11769 case ssiBOMBBAG:
11770 temp_sub->d1 = itype_bombbag;
11771 break;
11772
11773 case ssiCBYRNA:
11774 temp_sub->d1 = itype_cbyrna;
11775 break;
11776
11777 case ssiROCS:
11778 temp_sub->d1 = itype_rocs;
11779 break;
11780
11781 case ssiHOVERBOOTS:
11782 temp_sub->d1 = itype_hoverboots;
11783 break;
11784
11785 case ssiSPINSCROLL:
11786 temp_sub->d1 = itype_spinscroll;
11787 break;
11788
11789 case ssiCROSSSCROLL:
11790 temp_sub->d1 = itype_crossscroll;
11791 break;
11792
11793 case ssiQUAKESCROLL:
11794 temp_sub->d1 = itype_quakescroll;
11795 break;
11796
11797 case ssiWHISPRING:
11798 temp_sub->d1 = itype_whispring;
11799 break;
11800
11801 case ssiCHARGERING:
11802 temp_sub->d1 = itype_chargering;
11803 break;
11804
11805 case ssiPERILSCROLL:
11806 temp_sub->d1 = itype_perilscroll;
11807 break;
11808
11809 case ssiWEALTHMEDAL:
11810 temp_sub->d1 = itype_wealthmedal;
11811 break;
11812
11813 case ssiHEARTRING:
11814 temp_sub->d1 = itype_heartring;
11815 break;
11816
11817 case ssiMAGICRING:
11818 temp_sub->d1 = itype_magicring;
11819 break;
11820
11821 case ssiSPINSCROLL2:
11822 temp_sub->d1 = itype_spinscroll2;
11823 break;
11824
11825 case ssiQUAKESCROLL2:
11826 temp_sub->d1 = itype_quakescroll2;
11827 break;
11828
11829 case ssiAGONY:
11830 temp_sub->d1 = itype_agony;
11831 break;
11832
11833 case ssiSTOMPBOOTS:
11834 temp_sub->d1 = itype_stompboots;
11835 break;
11836
11837 case ssiWHIMSICALRING:
11838 temp_sub->d1 = itype_whimsicalring;
11839 break;
11840
11841 case ssiPERILRING:
11842 temp_sub->d1 = itype_perilring;
11843 break;
11844
11845 default:
11846 temp_sub->d1 += itype_custom1 - ssiMAX;
11847 }
11848 }
11849
11850 //fall-through
11851 default:
11852
1/2
✓ Branch 0 taken 18489 times.
✗ Branch 1 not taken.
18489 if(!p_getc(&(temp_sub->dp1),f,keepdata))
11853 {
11854 return qe_invalid;
11855 }
11856
11857 18489 break;
11858 }
11859
11860
2/2
✓ Branch 0 taken 11884 times.
✓ Branch 1 taken 8377 times.
20261 if(s_version < 7)
11861 {
11862
3/3
✓ Branch 0 taken 7837 times.
✓ Branch 1 taken 204 times.
✓ Branch 2 taken 336 times.
8377 switch(temp_sub->type)
11863 {
11864 case ssoMAGICGAUGE:
11865 {
11866
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 192 times.
204 if(!temp_sub->d9)
11867 192 temp_sub->d9 = -1; //-1 now represents 'always'
11868 204 break;
11869 }
11870 case ssoLIFEGAUGE:
11871 336 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11872 336 break;
11873 }
11874 8377 }
11875
11876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20261 times.
20261 if(keepdata)
11877 {
11878
3/3
✓ Branch 0 taken 1629 times.
✓ Branch 1 taken 17756 times.
✓ Branch 2 taken 876 times.
20261 switch(temp_sub->type)
11879 {
11880 case ssoTEXT:
11881 case ssoTEXTBOX:
11882 case ssoCURRENTITEMTEXT:
11883 case ssoCURRENTITEMCLASSTEXT:
11884
1/4
✓ Branch 0 taken 1629 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1629 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11885
11886 1629 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11887 1629 custom_subscreen[i].objects[j].dp1 = NULL;
11888 1629 custom_subscreen[i].objects[j].dp1 = new char[temp_size+1];
11889 1629 strcpy((char*)custom_subscreen[i].objects[j].dp1,(char*)temp_sub->dp1);
11890 1629 break;
11891
11892 case ssoCOUNTER:
11893
1/2
✓ Branch 0 taken 876 times.
✗ Branch 1 not taken.
876 if(s_version<3)
11894 {
11895 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11896 temp_sub->d8=0;
11897 }
11898
11899 default:
11900 18632 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11901 18632 break;
11902 }
11903
11904 20261 strcpy(custom_subscreen[i].name, tempname);
11905 20261 custom_subscreen[i].ss_type = temp_ss;
11906 20261 }
11907 20261 }
11908
11909
2/2
✓ Branch 0 taken 3158235 times.
✓ Branch 1 taken 12416 times.
3170651 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11910 {
11911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3158235 times.
3158235 if(keepdata)
11912 {
11913 //clear all unused object in this subscreen -DD
11914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3158235 times.
3158235 switch(custom_subscreen[i].objects[j].type)
11915 {
11916 case ssoTEXT:
11917 case ssoTEXTBOX:
11918 case ssoCURRENTITEMTEXT:
11919 case ssoCURRENTITEMCLASSTEXT:
11920 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11921
11922 //fall through
11923 default:
11924 3158235 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11925 3158235 break;
11926 }
11927 3158235 }
11928 3158235 }
11929
11930 12416 return 0;
11931 12416 }
11932
11933 2560 void reset_subscreen(subscreen_group *tempss)
11934 {
11935
2/2
✓ Branch 0 taken 655360 times.
✓ Branch 1 taken 2560 times.
657920 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11936 {
11937
2/2
✓ Branch 0 taken 131 times.
✓ Branch 1 taken 655229 times.
655360 switch(tempss->objects[i].type)
11938 {
11939 case ssoTEXT:
11940 case ssoTEXTBOX:
11941 case ssoCURRENTITEMTEXT:
11942 case ssoCURRENTITEMCLASSTEXT:
11943
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✓ Branch 2 taken 131 times.
✗ Branch 3 not taken.
131 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11944
11945 //fall through
11946 default:
11947 655360 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11948 655360 break;
11949 }
11950 655360 }
11951 2560 }
11952
11953 20 void reset_subscreens()
11954 {
11955
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 20 times.
2580 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11956 {
11957 2560 reset_subscreen(&custom_subscreen[i]);
11958 2560 }
11959 20 }
11960
11961 20 int32_t setupsubscreens()
11962 {
11963 20 reset_subscreens();
11964 20 int32_t tempsubscreen=zinit.subscreen;
11965 subscreen_object *tempsub;
11966
11967
1/2
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
20 if(tempsubscreen>=ssdtMAX)
11968 {
11969 tempsubscreen=0;
11970 }
11971
11972
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 switch(tempsubscreen)
11973 {
11974 case ssdtOLD:
11975 case ssdtNEWSUBSCR:
11976 case ssdtREV2:
11977 case ssdtBSZELDA:
11978 case ssdtBSZELDAMODIFIED:
11979 case ssdtBSZELDAENHANCED:
11980 case ssdtBSZELDACOMPLETE:
11981 {
11982 20 tempsub = default_subscreen_active[tempsubscreen][0];
11983 int32_t i;
11984
11985
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1320 times.
✓ Branch 2 taken 1300 times.
✓ Branch 3 taken 20 times.
1320 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11986 {
11987
2/3
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1244 times.
✗ Branch 2 not taken.
1300 switch(tempsub[i].type)
11988 {
11989 case ssoTEXT:
11990 case ssoTEXTBOX:
11991 case ssoCURRENTITEMTEXT:
11992 case ssoCURRENTITEMCLASSTEXT:
11993
1/4
✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
56 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11994
11995 56 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11996 56 custom_subscreen[0].objects[i].dp1 = NULL;
11997 56 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11998 56 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11999 56 break;
12000
12001 case ssoLIFEMETER:
12002 {
12003 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12004
12005 if(get_bit(deprecated_rules, 12) != 0)
12006 custom_subscreen[0].objects[i].d3=1;
12007 else
12008 custom_subscreen[0].objects[i].d3=0;
12009
12010 break;
12011 }
12012 /*
12013 case ssoTRIFRAME:
12014 {
12015 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12016 custom_subscreen[0].objects[i].d1 = 8594;
12017 custom_subscreen[0].objects[i].d2 = 8;
12018 custom_subscreen[0].objects[i].d3 = 8771;
12019 custom_subscreen[0].objects[i].d4 = 8;
12020 custom_subscreen[0].objects[i].d5 = 1;
12021 custom_subscreen[0].objects[i].d6 = 1;
12022 break;
12023 }*/
12024
12025 default:
12026 1244 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12027 1244 break;
12028 }
12029 1300 }
12030
12031 20 custom_subscreen[0].ss_type=sstACTIVE;
12032 20 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
12033 20 tempsub = default_subscreen_active[tempsubscreen][1];
12034
12035
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1320 times.
✓ Branch 2 taken 1300 times.
✓ Branch 3 taken 20 times.
1320 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12036 {
12037
2/3
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 1228 times.
✗ Branch 2 not taken.
1300 switch(tempsub[i].type)
12038 {
12039 case ssoTEXT:
12040 case ssoTEXTBOX:
12041 case ssoCURRENTITEMTEXT:
12042 case ssoCURRENTITEMCLASSTEXT:
12043
1/4
✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12044
12045 72 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12046 72 custom_subscreen[1].objects[i].dp1 = NULL;
12047 72 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12048 72 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12049 72 break;
12050
12051 case ssoLIFEMETER:
12052 {
12053 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12054
12055 if(get_bit(deprecated_rules, 12) != 0)
12056 custom_subscreen[1].objects[i].d3=1;
12057 else
12058 custom_subscreen[1].objects[i].d3=0;
12059
12060 break;
12061 }
12062 /*
12063 case ssoTRIFRAME:
12064 {
12065 custom_subscreen[1].objects[i].d1 = 8594;
12066 custom_subscreen[1].objects[i].d2 = 8;
12067 custom_subscreen[1].objects[i].d3 = 8771;
12068 custom_subscreen[1].objects[i].d4 = 8;
12069 custom_subscreen[1].objects[i].d5 = 1;
12070 custom_subscreen[1].objects[i].d6 = 1;
12071 break;
12072 }*/
12073
12074 default:
12075 1228 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12076 1228 break;
12077 }
12078 1300 }
12079
12080 20 custom_subscreen[1].ss_type=sstACTIVE;
12081 20 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12082 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12083 20 tempsub = default_subscreen_passive[tempsubscreen][0];
12084
12085
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
✓ Branch 2 taken 400 times.
✓ Branch 3 taken 20 times.
420 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12086 {
12087
3/3
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 320 times.
✓ Branch 2 taken 20 times.
400 switch(tempsub[i].type)
12088 {
12089 case ssoTEXT:
12090 case ssoTEXTBOX:
12091 case ssoCURRENTITEMTEXT:
12092 case ssoCURRENTITEMCLASSTEXT:
12093
1/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12094
12095 60 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12096 60 custom_subscreen[2].objects[i].dp1 = NULL;
12097 60 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12098 60 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12099 60 break;
12100
12101 case ssoLIFEMETER:
12102 {
12103 20 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12104
12105
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15 times.
20 if(get_bit(deprecated_rules, 12) != 0)
12106 5 custom_subscreen[2].objects[i].d3=1;
12107 else
12108 15 custom_subscreen[2].objects[i].d3=0;
12109
12110 20 break;
12111 }
12112
12113 default:
12114 320 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12115 320 break;
12116 }
12117 400 }
12118
12119 20 custom_subscreen[2].ss_type=sstPASSIVE;
12120 20 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12121 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12122 20 tempsub = default_subscreen_passive[tempsubscreen][1];
12123
12124
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 400 times.
✓ Branch 2 taken 380 times.
✓ Branch 3 taken 20 times.
400 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12125 {
12126
3/3
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 300 times.
✓ Branch 2 taken 20 times.
380 switch(tempsub[i].type)
12127 {
12128 case ssoTEXT:
12129 case ssoTEXTBOX:
12130 case ssoCURRENTITEMTEXT:
12131 case ssoCURRENTITEMCLASSTEXT:
12132
1/4
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12133
12134 60 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12135 60 custom_subscreen[3].objects[i].dp1 = NULL;
12136 60 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12137 60 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12138 60 break;
12139
12140 case ssoLIFEMETER:
12141 {
12142 20 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12143
12144
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 15 times.
20 if(get_bit(deprecated_rules, 12) != 0)
12145 5 custom_subscreen[3].objects[i].d3=1;
12146 else
12147 15 custom_subscreen[3].objects[i].d3=0;
12148
12149 20 break;
12150 }
12151
12152 default:
12153 300 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12154 300 break;
12155 }
12156 380 }
12157
12158 20 custom_subscreen[3].ss_type=sstPASSIVE;
12159 20 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12160 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12161 20 break;
12162 }
12163
12164 case ssdtZ3:
12165 {
12166 tempsub = z3_active_a;
12167 int32_t i;
12168
12169 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12170 {
12171 switch(tempsub[i].type)
12172 {
12173 case ssoTEXT:
12174 case ssoTEXTBOX:
12175 case ssoCURRENTITEMTEXT:
12176 case ssoCURRENTITEMCLASSTEXT:
12177 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12178
12179 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12180 custom_subscreen[0].objects[i].dp1 = NULL;
12181 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12182 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12183 break;
12184
12185 case ssoLIFEMETER:
12186 {
12187 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12188
12189 if(get_bit(deprecated_rules, 12) != 0)
12190 custom_subscreen[0].objects[i].d3=1;
12191 else
12192 custom_subscreen[0].objects[i].d3=0;
12193
12194 break;
12195 }
12196
12197 default:
12198 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12199 break;
12200 }
12201 }
12202
12203 custom_subscreen[0].ss_type=sstACTIVE;
12204 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12205 tempsub = z3_active_ab;
12206
12207 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12208 {
12209 switch(tempsub[i].type)
12210 {
12211 case ssoTEXT:
12212 case ssoTEXTBOX:
12213 case ssoCURRENTITEMTEXT:
12214 case ssoCURRENTITEMCLASSTEXT:
12215 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12216
12217 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12218 custom_subscreen[1].objects[i].dp1 = NULL;
12219 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12220 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12221 break;
12222
12223 case ssoLIFEMETER:
12224 {
12225 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12226
12227 if(get_bit(deprecated_rules, 12) != 0)
12228 custom_subscreen[1].objects[i].d3=1;
12229 else
12230 custom_subscreen[1].objects[i].d3=0;
12231
12232 break;
12233 }
12234
12235 default:
12236 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12237 break;
12238 }
12239 }
12240
12241 custom_subscreen[1].ss_type=sstACTIVE;
12242 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12243 tempsub = z3_passive_a;
12244
12245 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12246 {
12247 switch(tempsub[i].type)
12248 {
12249 case ssoTEXT:
12250 case ssoTEXTBOX:
12251 case ssoCURRENTITEMTEXT:
12252 case ssoCURRENTITEMCLASSTEXT:
12253 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12254
12255 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12256 custom_subscreen[2].objects[i].dp1 = NULL;
12257 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12258 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12259 break;
12260
12261 case ssoLIFEMETER:
12262 {
12263 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12264
12265 if(get_bit(deprecated_rules, 12) != 0)
12266 custom_subscreen[2].objects[i].d3=1;
12267 else
12268 custom_subscreen[2].objects[i].d3=0;
12269
12270 break;
12271 }
12272
12273 default:
12274 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12275 break;
12276 }
12277 }
12278
12279 custom_subscreen[2].ss_type=sstPASSIVE;
12280 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12281 tempsub = z3_passive_ab;
12282
12283 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12284 {
12285 switch(tempsub[i].type)
12286 {
12287 case ssoTEXT:
12288 case ssoTEXTBOX:
12289 case ssoCURRENTITEMTEXT:
12290 case ssoCURRENTITEMCLASSTEXT:
12291 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12292
12293 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12294 custom_subscreen[3].objects[i].dp1 = NULL;
12295 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12296 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12297 break;
12298
12299 case ssoLIFEMETER:
12300 {
12301 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12302
12303 if(get_bit(deprecated_rules, 12) != 0)
12304 custom_subscreen[3].objects[i].d3=1;
12305 else
12306 custom_subscreen[3].objects[i].d3=0;
12307
12308 break;
12309 }
12310
12311 default:
12312 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12313 break;
12314 }
12315 }
12316
12317 custom_subscreen[3].ss_type=sstPASSIVE;
12318 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12319 break;
12320 }
12321 }
12322
12323
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 80 times.
100 for(int32_t i=0; i<4; ++i)
12324 {
12325 80 purge_blank_subscreen_objects(&custom_subscreen[i]);
12326 80 }
12327
12328 20 return 0;
12329 }
12330
12331 extern script_data *ffscripts[NUMSCRIPTFFC];
12332 extern script_data *itemscripts[NUMSCRIPTITEM];
12333 extern script_data *guyscripts[NUMSCRIPTGUYS];
12334 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12335 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12336 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12337 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12338 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12339 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12340 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12341 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12342 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12343 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12344 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12345
12346
12347
12348 97 int32_t readffscript(PACKFILE *f, zquestheader *Header, bool keepdata)
12349 {
12350 int32_t dummy;
12351 97 word s_version=0, s_cversion=0, zmeta_version=0;
12352 97 byte numscripts=0;
12353 97 numscripts=numscripts; //to avoid unused variables warnings
12354 int32_t ret;
12355
12356 //section version info
12357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
12358 {
12359 return qe_invalid;
12360 }
12361
12362 97 FFCore.quest_format[vFFScript] = s_version;
12363
12364
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
12365 {
12366 return qe_invalid;
12367 }
12368
12369
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >= 18)
12370 {
12371
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&zmeta_version,f,true))
12372 {
12373 return qe_invalid;
12374 }
12375 23 }
12376
12377 //al_trace("Scripts version %d\n", s_version);
12378 //section size
12379
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy,f,true))
12380 {
12381 return qe_invalid;
12382 }
12383
12384 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12385 97 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12386 97 temp_ffscript_version = s_version;
12387 //miscQdata *the_misc;
12388
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12389 97 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12390
12391 //finally... section data
12392
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 97 times.
49761 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12393 {
12394 49664 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12395
12396
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(ret != 0) return qe_invalid;
12397 49664 }
12398
12399 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12400 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12401 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12402 * there was a version bump a week before a change that broke stuff.
12403 */
12404
6/8
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✓ Branch 4 taken 23 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 23 times.
✓ Branch 7 taken 74 times.
97 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)) && keepdata)
12405 {
12406 74 set_bit(quest_rules,qr_SPRITE_JUMP_IS_TRUNCATED,1);
12407 74 }
12408
3/4
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 74 times.
97 if(s_version < 19 && keepdata)
12409 {
12410 74 set_bit(quest_rules,qr_FLUCTUATING_ENEMY_JUMP,1);
12411 74 }
12412
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version > 1)
12414 {
12415
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12416 {
12417 24832 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12418
12419
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(ret != 0) return qe_invalid;
12420 24832 }
12421
12422
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12423 {
12424 24832 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12425
12426
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(ret != 0) return qe_invalid;
12427 24832 }
12428
12429
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12430 {
12431 24832 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12432
12433
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(ret != 0) return qe_invalid;
12434 24832 }
12435
12436
12437
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12438 {
12439 24832 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12440
12441
1/2
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
24832 if(ret != 0) return qe_invalid;
12442 24832 }
12443
12444
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if(s_version > 16)
12445 {
12446
2/2
✓ Branch 0 taken 184 times.
✓ Branch 1 taken 23 times.
207 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12447 {
12448 184 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12449
12450
1/2
✓ Branch 0 taken 184 times.
✗ Branch 1 not taken.
184 if(ret != 0) return qe_invalid;
12451 184 }
12452 23 }
12453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 else if(s_version > 13)
12454 {
12455 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12456 {
12457 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12458
12459 if(ret != 0) return qe_invalid;
12460 }
12461
12462 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12463 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12464
12465 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12466 }
12467
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 else if(s_version > 4)
12468 {
12469
2/2
✓ Branch 0 taken 296 times.
✓ Branch 1 taken 74 times.
370 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12470 {
12471 296 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12472
12473
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(ret != 0) return qe_invalid;
12474 296 }
12475
12476
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12477
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12478
12479
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12480
12481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12482
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12483
12484
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12485
12486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12487
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_F6];
12488
12489
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12490
12491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12492
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12493
12494
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12495 74 }
12496 else
12497 {
12498 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12499 {
12500 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12501
12502 if(ret != 0) return qe_invalid;
12503 }
12504
12505 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12506 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12507
12508 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12509
12510 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12511 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12512
12513 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12514
12515 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12516 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12517
12518 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12519
12520 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12521 delete globalscripts[GLOBAL_SCRIPT_F6];
12522
12523 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12524
12525 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12526 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12527
12528 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12529 }
12530
12531
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if(s_version > 10) //expanded the number of Player scripts to 5.
12532 {
12533
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 23 times.
138 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12534 {
12535 115 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12536
12537
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(ret != 0) return qe_invalid;
12538 115 }
12539 23 }
12540 else
12541 {
12542
2/2
✓ Branch 0 taken 222 times.
✓ Branch 1 taken 74 times.
296 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12543 {
12544 222 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12545
12546
1/2
✓ Branch 0 taken 222 times.
✗ Branch 1 not taken.
222 if(ret != 0) return qe_invalid;
12547 222 }
12548
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[3] != NULL)
12549
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 delete playerscripts[3];
12550
12551
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[3] = new script_data();
12552
12553
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 if(playerscripts[4] != NULL)
12554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 74 times.
74 delete playerscripts[4];
12555
12556
1/2
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
74 playerscripts[4] = new script_data();
12557 }
12558
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
97 if(s_version > 8 && s_version < 10)
12559 {
12560
12561 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12562 {
12563 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12564
12565 if(ret != 0) return qe_invalid;
12566 }
12567 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12568 {
12569 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12570
12571 if(ret != 0) return qe_invalid;
12572 }
12573
12574 }
12575
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >= 10)
12576 {
12577
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12578 {
12579 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12580
12581
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12582 5888 }
12583
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12584 {
12585 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12586
12587
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12588 5888 }
12589
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12590 {
12591 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12592
12593
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12594 5888 }
12595
12596 23 }
12597
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >=12)
12598 {
12599
2/2
✓ Branch 0 taken 5888 times.
✓ Branch 1 taken 23 times.
5911 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12600 {
12601 5888 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12602
12603
1/2
✓ Branch 0 taken 5888 times.
✗ Branch 1 not taken.
5888 if(ret != 0) return qe_invalid;
12604 5888 }
12605 23 }
12606
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >=15)
12607 {
12608
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12609 {
12610 11776 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12611
12612
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(ret != 0) return qe_invalid;
12613 11776 }
12614 23 }
12615
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >19)
12616 {
12617 23 word numgenscripts = NUMSCRIPTSGENERIC;
12618
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&numgenscripts,f,true))
12619 {
12620 return qe_invalid;
12621 }
12622
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i = 0; i < numgenscripts; i++)
12623 {
12624 11776 ret = read_one_ffscript(f, Header, keepdata, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12625
12626
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(ret != 0) return qe_invalid;
12627 11776 }
12628 23 }
12629
12630 /*
12631 else //Is this trip really necessary?
12632 {
12633 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12634 {
12635
12636 ewpnscripts[i] = NULL;
12637 }
12638 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12639 {
12640 dmapscripts[i] = NULL;
12641 }
12642 }
12643 */
12644
12645 97 }
12646
12647
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version > 2)
12648 {
12649 int32_t bufsize;
12650 97 p_igetl(&bufsize, f, true);
12651 97 char * buf = new char[bufsize+1];
12652 97 pfread(buf, bufsize, f, true);
12653 97 buf[bufsize]=0;
12654
12655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata)
12656
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 zScript = string(buf);
12657
12658
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 delete[] buf;
12659 word numffcbindings;
12660 97 p_igetw(&numffcbindings, f, true);
12661
12662
2/2
✓ Branch 0 taken 970 times.
✓ Branch 1 taken 97 times.
1067 for(int32_t i=0; i<numffcbindings; i++)
12663 {
12664 word id;
12665 970 p_igetw(&id, f, true);
12666 970 p_igetl(&bufsize, f, true);
12667 970 buf = new char[bufsize+1];
12668 970 pfread(buf, bufsize, f, true);
12669 970 buf[bufsize]=0;
12670
12671 //fix for buggy older saved quests -DD
12672
2/4
✓ Branch 0 taken 970 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 970 times.
970 if(keepdata && id < NUMSCRIPTFFC-1)
12673 970 ffcmap[id].scriptname = buf;
12674
12675
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 delete[] buf;
12676 970 }
12677
12678 word numglobalbindings;
12679 97 p_igetw(&numglobalbindings, f, true);
12680
12681
2/2
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 97 times.
496 for(int32_t i=0; i<numglobalbindings; i++)
12682 {
12683 word id;
12684 399 p_igetw(&id, f, true);
12685 399 p_igetl(&bufsize, f, true);
12686 399 buf = new char[bufsize+1];
12687 399 pfread(buf, bufsize, f, true);
12688 399 buf[bufsize]=0;
12689
12690 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12691 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12692 // Ignore these. -DD
12693
4/6
✓ Branch 0 taken 399 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 159 times.
✓ Branch 5 taken 240 times.
399 if(keepdata && id >= 0 && id < NUMSCRIPTGLOBAL)
12694 {
12695 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12696
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(strcmp(buf,"~Continue") == 0)
12697 {
12698 globalmap[id].scriptname = "";
12699
12700 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12701 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12702 }
12703 else
12704 {
12705 240 globalmap[id].scriptname = buf;
12706 }
12707 240 }
12708
12709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 399 times.
399 delete[] buf;
12710 399 }
12711
12712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version > 3)
12713 {
12714 word numitembindings;
12715 97 p_igetw(&numitembindings, f, true);
12716
12717
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 97 times.
178 for(int32_t i=0; i<numitembindings; i++)
12718 {
12719 word id;
12720 81 p_igetw(&id, f, true);
12721 81 p_igetl(&bufsize, f, true);
12722 81 buf = new char[bufsize+1];
12723 81 pfread(buf, bufsize, f, true);
12724 81 buf[bufsize]=0;
12725
12726 //fix this too
12727
2/4
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
81 if(keepdata && id <NUMSCRIPTITEM-1)
12728 81 itemmap[id].scriptname = buf;
12729
12730
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 delete[] buf;
12731 81 }
12732 97 }
12733 //(v9+)
12734
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version > 8)
12735 {
12736 //npc scripts
12737 word numnpcbindings;
12738 23 p_igetw(&numnpcbindings, f, true);
12739
12740
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 23 times.
35 for(int32_t i=0; i<numnpcbindings; i++)
12741 {
12742 word id;
12743 12 p_igetw(&id, f, true);
12744 12 p_igetl(&bufsize, f, true);
12745 12 buf = new char[bufsize+1];
12746 12 pfread(buf, bufsize, f, true);
12747 12 buf[bufsize]=0;
12748
12749 //fix this too
12750
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 if(keepdata && id <NUMSCRIPTGUYS-1)
12751 12 npcmap[id].scriptname = buf;
12752
12753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12754 12 }
12755 //lweapon
12756 word numlwpnbindings;
12757 23 p_igetw(&numlwpnbindings, f, true);
12758
12759
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 23 times.
65 for(int32_t i=0; i<numlwpnbindings; i++)
12760 {
12761 word id;
12762 42 p_igetw(&id, f, true);
12763 42 p_igetl(&bufsize, f, true);
12764 42 buf = new char[bufsize+1];
12765 42 pfread(buf, bufsize, f, true);
12766 42 buf[bufsize]=0;
12767
12768 //fix this too
12769
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12770 42 lwpnmap[id].scriptname = buf;
12771
12772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 delete[] buf;
12773 42 }
12774 //eweapon
12775 word numewpnbindings;
12776 23 p_igetw(&numewpnbindings, f, true);
12777
12778
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 23 times.
86 for(int32_t i=0; i<numewpnbindings; i++)
12779 {
12780 word id;
12781 63 p_igetw(&id, f, true);
12782 63 p_igetl(&bufsize, f, true);
12783 63 buf = new char[bufsize+1];
12784 63 pfread(buf, bufsize, f, true);
12785 63 buf[bufsize]=0;
12786
12787 //fix this too
12788
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 63 times.
63 if(keepdata && id <NUMSCRIPTWEAPONS-1)
12789 63 ewpnmap[id].scriptname = buf;
12790
12791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12792 63 }
12793 //hero
12794 word numherobindings;
12795 23 p_igetw(&numherobindings, f, true);
12796
12797
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 23 times.
27 for(int32_t i=0; i<numherobindings; i++)
12798 {
12799 word id;
12800 4 p_igetw(&id, f, true);
12801 4 p_igetl(&bufsize, f, true);
12802 4 buf = new char[bufsize+1];
12803 4 pfread(buf, bufsize, f, true);
12804 4 buf[bufsize]=0;
12805
12806 //fix this too
12807
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(keepdata && id <NUMSCRIPTPLAYER-1)
12808 4 playermap[id].scriptname = buf;
12809
12810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 delete[] buf;
12811 4 }
12812 //dmaps
12813 word numdmapbindings;
12814 23 p_igetw(&numdmapbindings, f, true);
12815
12816
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 23 times.
37 for(int32_t i=0; i<numdmapbindings; i++)
12817 {
12818 word id;
12819 14 p_igetw(&id, f, true);
12820 14 p_igetl(&bufsize, f, true);
12821 14 buf = new char[bufsize+1];
12822 14 pfread(buf, bufsize, f, true);
12823 14 buf[bufsize]=0;
12824
12825 //fix this too
12826
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSDMAP-1)
12827 14 dmapmap[id].scriptname = buf;
12828
12829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12830 14 }
12831 //screen
12832 word numscreenbindings;
12833 23 p_igetw(&numscreenbindings, f, true);
12834
12835
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 23 times.
34 for(int32_t i=0; i<numscreenbindings; i++)
12836 {
12837 word id;
12838 11 p_igetw(&id, f, true);
12839 11 p_igetl(&bufsize, f, true);
12840 11 buf = new char[bufsize+1];
12841 11 pfread(buf, bufsize, f, true);
12842 11 buf[bufsize]=0;
12843
12844 //fix this too
12845
2/4
✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
11 if(keepdata && id <NUMSCRIPTSDMAP-1)
12846 11 screenmap[id].scriptname = buf;
12847
12848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11 times.
11 delete[] buf;
12849 11 }
12850 23 }
12851
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version > 11)
12852 {
12853 word numspritebindings;
12854 23 p_igetw(&numspritebindings, f, true);
12855
12856
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 23 times.
33 for(int32_t i=0; i<numspritebindings; i++)
12857 {
12858 word id;
12859 10 p_igetw(&id, f, true);
12860 10 p_igetl(&bufsize, f, true);
12861 10 buf = new char[bufsize+1];
12862 10 pfread(buf, bufsize, f, true);
12863 10 buf[bufsize]=0;
12864
12865 //fix this too
12866
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if(keepdata && id <NUMSCRIPTSDMAP-1)
12867 10 itemspritemap[id].scriptname = buf;
12868
12869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 delete[] buf;
12870 10 }
12871 23 }
12872
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version >= 15)
12873 {
12874 word numcombobindings;
12875 23 p_igetw(&numcombobindings, f, true);
12876
12877
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 23 times.
47 for(int32_t i=0; i<numcombobindings; i++)
12878 {
12879 word id;
12880 24 p_igetw(&id, f, true);
12881 24 p_igetl(&bufsize, f, true);
12882 24 buf = new char[bufsize+1];
12883 24 pfread(buf, bufsize, f, true);
12884 24 buf[bufsize]=0;
12885
12886 //fix this too
12887
2/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24 times.
24 if(keepdata && id <NUMSCRIPTSCOMBODATA-1)
12888 24 comboscriptmap[id].scriptname = buf;
12889
12890
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 delete[] buf;
12891 24 }
12892 23 }
12893
2/2
✓ Branch 0 taken 74 times.
✓ Branch 1 taken 23 times.
97 if(s_version > 19)
12894 {
12895 word numgenericbindings;
12896 23 p_igetw(&numgenericbindings, f, true);
12897
12898
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 23 times.
37 for(int32_t i=0; i<numgenericbindings; i++)
12899 {
12900 word id;
12901 14 p_igetw(&id, f, true);
12902 14 p_igetl(&bufsize, f, true);
12903 14 buf = new char[bufsize+1];
12904 14 pfread(buf, bufsize, f, true);
12905 14 buf[bufsize]=0;
12906
12907 //fix this too
12908
2/4
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
14 if(keepdata && id <NUMSCRIPTSGENERIC-1)
12909 14 genericmap[id].scriptname = buf;
12910
12911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 delete[] buf;
12912 14 }
12913 23 }
12914 97 }
12915
12916 97 return 0;
12917 97 }
12918
12919 104 void reset_scripts()
12920 {
12921 //OK, who spaced this? ;)
12922
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12923 {
12924
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53248 times.
53248 if(ffscripts[i]!=NULL) delete ffscripts[i];
12925 53248 }
12926
12927
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12928 {
12929
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(itemscripts[i]!=NULL) delete itemscripts[i];
12930 26624 }
12931
12932
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12933 {
12934
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(guyscripts[i]!=NULL) delete guyscripts[i];
12935 26624 }
12936
12937
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12938 {
12939
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(wpnscripts[i]!=NULL) delete wpnscripts[i];
12940 26624 }
12941
12942
12943
12944
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12945 {
12946
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(screenscripts[i]!=NULL) delete screenscripts[i];
12947 26624 }
12948
12949
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 104 times.
936 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12950 {
12951
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 832 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 832 times.
832 if(globalscripts[i]!=NULL) delete globalscripts[i];
12952 832 }
12953
12954
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 104 times.
624 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12955 {
12956
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 520 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 520 times.
520 if(playerscripts[i]!=NULL) delete playerscripts[i];
12957 520 }
12958
12959
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12960 {
12961
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(lwpnscripts[i]!=NULL) delete lwpnscripts[i];
12962 26624 }
12963
12964
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12965 {
12966
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(ewpnscripts[i]!=NULL) delete ewpnscripts[i];
12967 26624 }
12968
12969
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12970 {
12971
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(dmapscripts[i]!=NULL) delete dmapscripts[i];
12972 26624 }
12973
12974
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12975 {
12976
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 26624 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26624 times.
26624 if(itemspritescripts[i]!=NULL) delete itemspritescripts[i];
12977 26624 }
12978
12979
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12980 {
12981
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 53248 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53248 times.
53248 if(comboscripts[i]!=NULL) delete comboscripts[i];
12982 53248 }
12983
12984 104 next_script_data_debug_id = 0;
12985
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12986 {
12987
3/4
✓ Branch 0 taken 15872 times.
✓ Branch 1 taken 37376 times.
✓ Branch 2 taken 37376 times.
✗ Branch 3 not taken.
53248 if(genericscripts[i]!=NULL) delete genericscripts[i];
12988
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 genericscripts[i] = new script_data();
12989 53248 }
12990
12991
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12992 {
12993
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 ffscripts[i] = new script_data();
12994 53248 }
12995
12996
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12997 {
12998
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 itemscripts[i] = new script_data();
12999 26624 }
13000
13001
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
13002 {
13003
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 guyscripts[i] = new script_data();
13004 26624 }
13005
13006
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13007 {
13008
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 wpnscripts[i] = new script_data();
13009 26624 }
13010
13011
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13012 {
13013
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 screenscripts[i] = new script_data();
13014 26624 }
13015
13016
2/2
✓ Branch 0 taken 832 times.
✓ Branch 1 taken 104 times.
936 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13017 {
13018
1/2
✓ Branch 0 taken 832 times.
✗ Branch 1 not taken.
832 globalscripts[i] = new script_data();
13019 832 }
13020
13021
2/2
✓ Branch 0 taken 520 times.
✓ Branch 1 taken 104 times.
624 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13022 {
13023
1/2
✓ Branch 0 taken 520 times.
✗ Branch 1 not taken.
520 playerscripts[i] = new script_data();
13024 520 }
13025
13026
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13027 {
13028
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 lwpnscripts[i] = new script_data();
13029 26624 }
13030
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13031 {
13032
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 ewpnscripts[i] = new script_data();
13033 26624 }
13034
13035
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13036 {
13037
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 dmapscripts[i] = new script_data();
13038 26624 }
13039
2/2
✓ Branch 0 taken 26624 times.
✓ Branch 1 taken 104 times.
26728 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13040 {
13041
1/2
✓ Branch 0 taken 26624 times.
✗ Branch 1 not taken.
26624 itemspritescripts[i] = new script_data();
13042 26624 }
13043
2/2
✓ Branch 0 taken 53248 times.
✓ Branch 1 taken 104 times.
53352 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13044 {
13045
1/2
✓ Branch 0 taken 53248 times.
✗ Branch 1 not taken.
53248 comboscripts[i] = new script_data();
13046 53248 }
13047 104 }
13048
13049 extern script_command command_list[];
13050 196913 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, bool keepdata, int32_t , word s_version, word , script_data **script, word zmeta_version)
13051 {
13052 //Please also update loadquest() when modifying this method -DD
13053 196913 char b33[34] = {0};
13054 196913 b33[33] = 0;
13055 196913 ffscript temp_script;
13056 196913 int32_t num_commands=1000;
13057
13058
1/2
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
196913 if(s_version>=2)
13059 {
13060
2/4
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196913 times.
✗ Branch 3 not taken.
196913 if(!p_igetl(&num_commands,f,true))
13061 {
13062 return qe_invalid;
13063 }
13064 196913 }
13065
13066
1/2
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
196913 if(keepdata)
13067 {
13068
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196913 times.
196913 if((*script) != NULL) //Surely we want to do this regardless of keepdata? //No, we don't -V
13069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 196913 times.
196913 delete (*script);
13070
2/4
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 196913 times.
✗ Branch 3 not taken.
196913 (*script) = new script_data(num_commands);
13071 196913 }
13072
2/2
✓ Branch 0 taken 82731 times.
✓ Branch 1 taken 114182 times.
196913 if(s_version >= 16)
13073 {
13074
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 zasm_meta temp_meta;
13075
13076
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.zasm_v),f,true))
13077 {
13078 return qe_invalid;
13079 }
13080
13081
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.meta_v),f,true))
13082 {
13083 return qe_invalid;
13084 }
13085
13086
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.ffscript_v),f,true))
13087 {
13088 return qe_invalid;
13089 }
13090
13091
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getc(&(temp_meta.script_type),f,true))
13092 {
13093 return qe_invalid;
13094 }
13095
13096
2/2
✓ Branch 0 taken 661848 times.
✓ Branch 1 taken 82731 times.
744579 for(int32_t q = 0; q < 8; ++q)
13097 {
13098
2/2
✓ Branch 0 taken 230208 times.
✓ Branch 1 taken 431640 times.
661848 if(zmeta_version < 3)
13099 {
13100
2/2
✓ Branch 0 taken 230208 times.
✓ Branch 1 taken 7596864 times.
7827072 for(int32_t c = 0; c < 33; ++c)
13101 {
13102
2/4
✓ Branch 0 taken 7596864 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7596864 times.
✗ Branch 3 not taken.
7596864 if(!p_getc(&(b33[c]),f,true))
13103 {
13104 return qe_invalid;
13105 }
13106 7596864 }
13107
1/2
✓ Branch 0 taken 230208 times.
✗ Branch 1 not taken.
230208 temp_meta.run_idens[q].assign(b33);
13108 230208 }
13109 else
13110 {
13111
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.run_idens[q],f,true))
13112 {
13113 return qe_invalid;
13114 }
13115 }
13116 661848 }
13117
13118
2/2
✓ Branch 0 taken 82731 times.
✓ Branch 1 taken 661848 times.
744579 for(int32_t q = 0; q < 8; ++q)
13119 {
13120
2/4
✓ Branch 0 taken 661848 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 661848 times.
✗ Branch 3 not taken.
661848 if(!p_getc(&(temp_meta.run_types[q]),f,true))
13121 {
13122 return qe_invalid;
13123 }
13124 661848 }
13125
13126
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_getc(&(temp_meta.flags),f,true))
13127 {
13128 return qe_invalid;
13129 }
13130
13131
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v1),f,true))
13132 {
13133 return qe_invalid;
13134 }
13135
13136
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v2),f,true))
13137 {
13138 return qe_invalid;
13139 }
13140
13141
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v3),f,true))
13142 {
13143 return qe_invalid;
13144 }
13145
13146
2/4
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 82731 times.
✗ Branch 3 not taken.
82731 if(!p_igetw(&(temp_meta.compiler_v4),f,true))
13147 {
13148 return qe_invalid;
13149 }
13150
13151
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 53955 times.
82731 if(zmeta_version == 2)
13152 {
13153
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 949608 times.
978384 for(int32_t c = 0; c < 33; ++c)
13154 {
13155
2/4
✓ Branch 0 taken 949608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 949608 times.
✗ Branch 3 not taken.
949608 if(!p_getc(&b33[c],f,true))
13156 {
13157 return qe_invalid;
13158 }
13159 949608 }
13160
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.script_name.assign(b33);
13161
13162
2/2
✓ Branch 0 taken 28776 times.
✓ Branch 1 taken 949608 times.
978384 for(int32_t c = 0; c < 33; ++c)
13163 {
13164
2/4
✓ Branch 0 taken 949608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 949608 times.
✗ Branch 3 not taken.
949608 if(!p_getc(&b33[c],f,true))
13165 {
13166 return qe_invalid;
13167 }
13168 949608 }
13169
1/2
✓ Branch 0 taken 28776 times.
✗ Branch 1 not taken.
28776 temp_meta.author.assign(b33);
13170 28776 }
13171
1/2
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
53955 else if(zmeta_version > 2)
13172 {
13173
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.script_name,f,true))
13174 return qe_invalid;
13175
2/4
✓ Branch 0 taken 53955 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 53955 times.
✗ Branch 3 not taken.
53955 if(!p_getcstr(&temp_meta.author,f,true))
13176 return qe_invalid;
13177 53955 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13178
2/2
✓ Branch 0 taken 539550 times.
✓ Branch 1 taken 53955 times.
593505 for(auto q = 0; q < num_meta_attrib; ++q)
13179 {
13180
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getcstr(&temp_meta.attributes[q],f,true))
13181 return qe_invalid;
13182
2/4
✓ Branch 0 taken 539550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 539550 times.
✗ Branch 3 not taken.
539550 if(!p_getwstr(&temp_meta.attributes_help[q],f,true))
13183 return qe_invalid;
13184 539550 }
13185
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13186 {
13187
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attribytes[q],f,true))
13188 return qe_invalid;
13189
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attribytes_help[q],f,true))
13190 return qe_invalid;
13191 431640 }
13192
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13193 {
13194
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.attrishorts[q],f,true))
13195 return qe_invalid;
13196
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.attrishorts_help[q],f,true))
13197 return qe_invalid;
13198 431640 }
13199
2/2
✓ Branch 0 taken 863280 times.
✓ Branch 1 taken 53955 times.
917235 for(auto q = 0; q < 16; ++q)
13200 {
13201
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getcstr(&temp_meta.usrflags[q],f,true))
13202 return qe_invalid;
13203
2/4
✓ Branch 0 taken 863280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 863280 times.
✗ Branch 3 not taken.
863280 if(!p_getwstr(&temp_meta.usrflags_help[q],f,true))
13204 return qe_invalid;
13205 863280 }
13206 53955 }
13207
2/2
✓ Branch 0 taken 53955 times.
✓ Branch 1 taken 28776 times.
82731 if(zmeta_version > 3)
13208 {
13209
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13210 {
13211
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getcstr(&temp_meta.initd[q],f,true))
13212 return qe_invalid;
13213
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getwstr(&temp_meta.initd_help[q],f,true))
13214 return qe_invalid;
13215 431640 }
13216
2/2
✓ Branch 0 taken 431640 times.
✓ Branch 1 taken 53955 times.
485595 for(auto q = 0; q < 8; ++q)
13217 {
13218
2/4
✓ Branch 0 taken 431640 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 431640 times.
✗ Branch 3 not taken.
431640 if(!p_getc(&temp_meta.initd_type[q],f,true))
13219 return qe_invalid;
13220 431640 }
13221 53955 }
13222 else
13223 {
13224
2/2
✓ Branch 0 taken 230208 times.
✓ Branch 1 taken 28776 times.
258984 for(auto q = 0; q < 8; ++q)
13225 {
13226
1/2
✓ Branch 0 taken 230208 times.
✗ Branch 1 not taken.
230208 temp_meta.initd[q] = temp_meta.run_idens[q];
13227 230208 }
13228 }
13229
13230
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 if(keepdata)
13231
1/2
✓ Branch 0 taken 82731 times.
✗ Branch 1 not taken.
82731 (*script)->meta = temp_meta;
13232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82731 times.
82731 }
13233
13234
1/2
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
196913 temp_script.clear();
13235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7771308 times.
7771308 for(int32_t j=0; j<num_commands; j++)
13236 {
13237
2/4
✓ Branch 0 taken 7771308 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7771308 times.
✗ Branch 3 not taken.
7771308 if(!p_igetw(&(temp_script.command),f,true))
13238 {
13239 return qe_invalid;
13240 }
13241
13242
2/2
✓ Branch 0 taken 7574395 times.
✓ Branch 1 taken 196913 times.
7771308 if(temp_script.command == 0xFFFF)
13243 {
13244
1/2
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
196913 if(keepdata)
13245
1/2
✓ Branch 0 taken 196913 times.
✗ Branch 1 not taken.
196913 (*script)->zasm[j].clear();
13246 196913 break;
13247 }
13248 else
13249 {
13250
2/4
✓ Branch 0 taken 7574395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574395 times.
✗ Branch 3 not taken.
7574395 if(!p_igetl(&(temp_script.arg1),f,keepdata))
13251 {
13252 return qe_invalid;
13253 }
13254
13255
2/4
✓ Branch 0 taken 7574395 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7574395 times.
✗ Branch 3 not taken.
7574395 if(!p_igetl(&(temp_script.arg2),f,keepdata))
13256 {
13257 return qe_invalid;
13258 }
13259
13260
2/2
✓ Branch 0 taken 451727 times.
✓ Branch 1 taken 7122668 times.
7574395 if(s_version >= 21)
13261 {
13262 451727 uint32_t sz = 0;
13263
2/4
✓ Branch 0 taken 451727 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451727 times.
✗ Branch 3 not taken.
451727 if(!p_igetl(&sz,f,keepdata))
13264 {
13265 return qe_invalid;
13266 }
13267
2/2
✓ Branch 0 taken 1522 times.
✓ Branch 1 taken 450205 times.
451727 if(sz) //string found
13268 {
13269
1/2
✓ Branch 0 taken 1522 times.
✗ Branch 1 not taken.
1522 temp_script.strptr = new std::string();
13270 char dummy;
13271
2/2
✓ Branch 0 taken 115152 times.
✓ Branch 1 taken 1522 times.
116674 for(size_t q = 0; q < sz; ++q)
13272 {
13273
2/4
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 115152 times.
✗ Branch 3 not taken.
115152 if(!p_getc(&dummy,f,keepdata))
13274 {
13275 return qe_invalid;
13276 }
13277
1/2
✓ Branch 0 taken 115152 times.
✗ Branch 1 not taken.
115152 temp_script.strptr->push_back(dummy);
13278 115152 }
13279 1522 }
13280
2/4
✓ Branch 0 taken 451727 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 451727 times.
✗ Branch 3 not taken.
451727 if(!p_igetl(&sz,f,keepdata))
13281 {
13282 return qe_invalid;
13283 }
13284
2/2
✓ Branch 0 taken 90 times.
✓ Branch 1 taken 451637 times.
451727 if(sz) //vector found
13285 {
13286
1/2
✓ Branch 0 taken 90 times.
✗ Branch 1 not taken.
90 temp_script.vecptr = new std::vector<int32_t>();
13287 int32_t dummy;
13288
2/2
✓ Branch 0 taken 1311 times.
✓ Branch 1 taken 90 times.
1401 for(size_t q = 0; q < sz; ++q)
13289 {
13290
2/4
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1311 times.
✗ Branch 3 not taken.
1311 if(!p_igetl(&dummy,f,keepdata))
13291 {
13292 return qe_invalid;
13293 }
13294
1/2
✓ Branch 0 taken 1311 times.
✗ Branch 1 not taken.
1311 temp_script.vecptr->push_back(dummy);
13295 1311 }
13296 90 }
13297 451727 }
13298
13299
1/2
✓ Branch 0 taken 7574395 times.
✗ Branch 1 not taken.
7574395 if(keepdata)
13300 {
13301
1/2
✓ Branch 0 taken 7574395 times.
✗ Branch 1 not taken.
7574395 temp_script.give((*script)->zasm[j]);
13302 7574395 }
13303 }
13304
1/2
✓ Branch 0 taken 7574395 times.
✗ Branch 1 not taken.
7574395 temp_script.clear();
13305 7574395 }
13306
13307 196913 return 0;
13308 196913 }
13309
13310 extern SAMPLE customsfxdata[WAV_COUNT];
13311 extern uint8_t customsfxflag[WAV_COUNT>>3];
13312 extern int32_t sfxdat;
13313 extern DATAFILE *sfxdata;
13314 const char *old_sfx_string[Z35] =
13315 {
13316 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13317 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13318 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13319 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13320 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13321 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13322 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13323 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13324 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13325 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13326 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13327 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13328 };
13329 char *sfx_string[WAV_COUNT];
13330
13331 97 int32_t readsfx(PACKFILE *f, zquestheader *Header, bool keepdata)
13332 {
13333 //these are here to bypass compiler warnings about unused arguments
13334 97 Header=Header;
13335
13336 int32_t dummy;
13337 97 word s_version=0, s_cversion=0;
13338 //int32_t ret;
13339 SAMPLE temp_sample;
13340 97 temp_sample.loop_start=0;
13341 97 temp_sample.loop_end=0;
13342 97 temp_sample.param=0;
13343
13344 //section version info
13345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
13346 {
13347 return qe_invalid;
13348 }
13349
13350 97 FFCore.quest_format[vSFX] = s_version;
13351
13352 //al_trace("SFX version %d\n", s_version);
13353
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
13354 {
13355 return qe_invalid;
13356 }
13357
13358 //section size
13359
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy,f,true))
13360 {
13361 return qe_invalid;
13362 }
13363
13364 /* HIGHLY UNORTHODOX UPDATING THING, by L
13365 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13366 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13367 * changing from 1 to 2.
13368 */
13369
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
97 if(s_version < 2 && keepdata)
13370 set_bit(quest_rules,qr_GOTOLESSNOTEQUAL,1);
13371
13372 /* End highly unorthodox updating thing */
13373
13374 97 int32_t wavcount = WAV_COUNT;
13375
13376
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version < 6)
13377 wavcount = 128;
13378
13379 uint8_t tempflag[WAV_COUNT>>3];
13380
13381
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version < 4)
13382 {
13383 memset(tempflag, 0xFF, WAV_COUNT>>3);
13384 }
13385 else
13386 {
13387
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version < 6)
13388 memset(tempflag, 0, WAV_COUNT>>3);
13389
13390
2/2
✓ Branch 0 taken 3104 times.
✓ Branch 1 taken 97 times.
3201 for(int32_t i=0; i<(wavcount>>3); i++)
13391 {
13392 3104 p_getc(&tempflag[i], f, true);
13393 3104 }
13394
13395 }
13396
13397
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version>4)
13398 {
13399
2/2
✓ Branch 0 taken 24735 times.
✓ Branch 1 taken 97 times.
24832 for(int32_t i=1; i<WAV_COUNT; i++)
13400 {
13401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24735 times.
24735 if(keepdata)
13402 {
13403 24735 sprintf(sfx_string[i],"s%03d",i);
13404
13405
2/2
✓ Branch 0 taken 18915 times.
✓ Branch 1 taken 5820 times.
24735 if((i<Z35))
13406 5820 strcpy(sfx_string[i], old_sfx_string[i-1]);
13407 24735 }
13408
13409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24735 times.
24735 if(i>=wavcount)
13410 continue;
13411
2/2
✓ Branch 0 taken 1904 times.
✓ Branch 1 taken 22831 times.
24735 if(get_bit(tempflag, i-1))
13412 {
13413 char tempname[36];
13414
13415
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!pfread(tempname, 36, f, keepdata))
13416 {
13417 return qe_invalid;
13418 }
13419
13420
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1904 times.
1904 if(keepdata)
13421 {
13422 1904 strcpy(sfx_string[i], tempname);
13423 1904 sfx_string[i][35] = 0; //Force NULL Termination
13424 1904 }
13425 1904 }
13426
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22831 times.
22831 else if(keepdata)
13427 {
13428 22831 sprintf(sfx_string[i],"s%03d",i);
13429
13430
2/2
✓ Branch 0 taken 18410 times.
✓ Branch 1 taken 4421 times.
22831 if(i<Z35)
13431 4421 strcpy(sfx_string[i], old_sfx_string[i-1]);
13432 22831 sfx_string[i][35] = 0; //Force NULL Termination
13433 22831 }
13434 24735 }
13435 97 }
13436 else
13437 {
13438 if(keepdata)
13439 {
13440 for(int32_t i=1; i<WAV_COUNT; i++)
13441 {
13442 sprintf(sfx_string[i],"s%03d",i);
13443
13444 if(i<Z35)
13445 strcpy(sfx_string[i], old_sfx_string[i-1]);
13446 }
13447 }
13448 }
13449
13450 //finally... section data
13451
2/2
✓ Branch 0 taken 24735 times.
✓ Branch 1 taken 97 times.
24832 for(int32_t i=1; i<wavcount; i++)
13452 {
13453
2/2
✓ Branch 0 taken 1904 times.
✓ Branch 1 taken 22831 times.
24735 if(get_bit(tempflag, i-1))
13454 {
13455
13456
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&dummy,f,true))
13457 {
13458 return qe_invalid;
13459 }
13460
13461 1904 (temp_sample.bits) = dummy;
13462
13463
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&dummy,f,true))
13464 {
13465 return qe_invalid;
13466 }
13467
13468 1904 (temp_sample.stereo) = dummy;
13469
13470
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&dummy,f,keepdata))
13471 {
13472 return qe_invalid;
13473 }
13474
13475 1904 (temp_sample.freq) = dummy;
13476
13477
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&dummy,f,keepdata))
13478 {
13479 return qe_invalid;
13480 }
13481
13482 1904 (temp_sample.priority) = dummy;
13483
13484
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&(temp_sample.len),f,true))
13485 {
13486 return qe_invalid;
13487 }
13488
13489
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&(temp_sample.loop_start),f,keepdata))
13490 {
13491 return qe_invalid;
13492 }
13493
13494
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&(temp_sample.loop_end),f,keepdata))
13495 {
13496 return qe_invalid;
13497 }
13498
13499
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(!p_igetl(&(temp_sample.param),f,keepdata))
13500 {
13501 return qe_invalid;
13502 }
13503
13504 // al_trace("F%i: L%i\n",i,temp_sample.len);
13505 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13506 1904 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13507 1904 temp_sample.data = calloc(len,1);
13508
13509
1/2
✓ Branch 0 taken 1904 times.
✗ Branch 1 not taken.
1904 if(s_version < 3)
13510 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13511
13512 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1904 times.
1904 if(s_version < 2)
13514 {
13515 if(!pfread(temp_sample.data, len,f,keepdata))
13516 {
13517 return qe_invalid;
13518 }
13519 }
13520 else
13521 {
13522 //re-endianfy the data
13523 1904 int32_t wordstoread = len / sizeof(word);
13524
13525
2/2
✓ Branch 0 taken 55488989 times.
✓ Branch 1 taken 1904 times.
55490893 for(int32_t j=0; j<wordstoread; j++)
13526 {
13527 word temp;
13528
13529
1/2
✓ Branch 0 taken 55488989 times.
✗ Branch 1 not taken.
55488989 if(!p_igetw(&temp, f, keepdata))
13530 {
13531 return qe_invalid;
13532 }
13533
13534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 55488989 times.
55488989 if(keepdata)
13535 55488989 ((word *)temp_sample.data)[j] = temp;
13536 55488989 }
13537 }
13538 1904 }
13539
2/2
✓ Branch 0 taken 4421 times.
✓ Branch 1 taken 18410 times.
22831 else if(i < Z35)
13540 {
13541 4421 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13542 4421 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13543 4421 set_bit(tempflag, i-1, 1);
13544 4421 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13545 4421 temp_sample.data = calloc(len,1);
13546 4421 memcpy(temp_sample.data, datsamp->data, len);
13547 4421 }
13548 18410 else continue;
13549
13550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6325 times.
6325 if(keepdata)
13551 {
13552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6325 times.
6325 if(customsfxdata[i].data!=NULL)
13553 {
13554 // delete [] customsfxdata[i].data;
13555 6325 free(customsfxdata[i].data);
13556 6325 }
13557
13558 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13559 6325 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13560 6325 customsfxdata[i].data = calloc(len2,1);
13561 6325 customsfxdata[i].bits = temp_sample.bits;
13562 6325 customsfxdata[i].stereo = temp_sample.stereo;
13563 6325 customsfxdata[i].freq = temp_sample.freq;
13564 6325 customsfxdata[i].priority = temp_sample.priority;
13565 6325 customsfxdata[i].len = temp_sample.len;
13566 6325 customsfxdata[i].loop_start = temp_sample.loop_start;
13567 6325 customsfxdata[i].loop_end = temp_sample.loop_end;
13568 6325 customsfxdata[i].param = temp_sample.param;
13569 6325 int32_t cpylen = len2;
13570
13571
1/2
✓ Branch 0 taken 6325 times.
✗ Branch 1 not taken.
6325 if(s_version<3)
13572 {
13573 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13574 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13575 }
13576
13577 6325 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13578 6325 }
13579
13580 6325 free(temp_sample.data);
13581 6325 }
13582
13583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata)
13584 97 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13585
13586 97 sfxdat=0;
13587 97 return 0;
13588 97 }
13589
13590 104 void setupsfx()
13591 {
13592
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=1; i<WAV_COUNT; i++)
13593 {
13594 26520 sprintf(sfx_string[i],"s%03d",i);
13595
13596
2/2
✓ Branch 0 taken 20280 times.
✓ Branch 1 taken 6240 times.
26520 if(i<Z35)
13597 {
13598 6240 strcpy(sfx_string[i], old_sfx_string[i-1]);
13599 6240 }
13600
13601 26520 memset(customsfxflag, 0, WAV_COUNT>>3);
13602
13603 26520 int32_t j=i;
13604
13605
2/2
✓ Branch 0 taken 6344 times.
✓ Branch 1 taken 20176 times.
26520 if(i>Z35)
13606 {
13607 20176 i=Z35;
13608 20176 }
13609
13610 26520 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13611
13612
2/2
✓ Branch 0 taken 7905 times.
✓ Branch 1 taken 18615 times.
26520 if(customsfxdata[j].data!=NULL)
13613 {
13614 // delete [] customsfxdata[j].data;
13615 18615 free(customsfxdata[j].data);
13616 18615 }
13617
13618 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13619 26520 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13620 26520 customsfxdata[j].bits = temp_sample->bits;
13621 26520 customsfxdata[j].stereo = temp_sample->stereo;
13622 26520 customsfxdata[j].freq = temp_sample->freq;
13623 26520 customsfxdata[j].priority = temp_sample->priority;
13624 26520 customsfxdata[j].len = temp_sample->len;
13625 26520 customsfxdata[j].loop_start = temp_sample->loop_start;
13626 26520 customsfxdata[j].loop_end = temp_sample->loop_end;
13627 26520 customsfxdata[j].param = temp_sample->param;
13628 26520 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13629 26520 i=j;
13630 26520 }
13631 104 }
13632
13633 extern char *guy_string[eMAXGUYS];
13634 extern const char *old_guy_string[OLDMAXGUYS];
13635
13636 104 int32_t readguys(PACKFILE *f, zquestheader *Header, bool keepdata)
13637 {
13638 dword dummy;
13639 word guy_cversion;
13640 104 word guyversion=0;
13641
13642
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version >= 0x193)
13643 {
13644 //section version info
13645
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&guyversion,f,true))
13646 {
13647 return qe_invalid;
13648 }
13649
13650 102 FFCore.quest_format[vGuys] = guyversion;
13651
13652 //al_trace("Guys version %d\n", guyversion);
13653
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&guy_cversion,f,true))
13654 {
13655 return qe_invalid;
13656 }
13657 102 al_trace("Guy CVersion is: %d\n", guy_cversion);
13658 //section size
13659
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
13660 {
13661 return qe_invalid;
13662 }
13663 102 }
13664
13665
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(guyversion > 3)
13666 {
13667
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 97 times.
49761 for(int32_t i=0; i<MAXGUYS; i++)
13668 {
13669 char tempname[64];
13670
13671 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13672 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13673
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
49664 if(guyversion < 23 && i >= OLDBETAMAXGUYS && keepdata)
13674 {
13675 memset(tempname, 0, sizeof(char)*64);
13676 sprintf(tempname, "e%03d", i);
13677 strcpy(guy_string[i], tempname);
13678
13679 continue;
13680 }
13681
13682
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!pfread(tempname, 64, f, keepdata))
13683 {
13684 return qe_invalid;
13685 }
13686
13687 // Don't retain names of uneditable enemy entries!
13688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
49664 if(keepdata)
13689 {
13690 // for version upgrade to 2.5
13691
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49664 if(guyversion < 23 && i >= 177)
13692 {
13693 // some of the older builds have names such as 'zz123',
13694 // (this order gets messed up with some eXXX and some zzXXX)
13695 // so let's update to the newer naming convection. -Gleeok
13696 char tmpbuf[64];
13697 memset(tmpbuf, 0, sizeof(char)*64);
13698 sprintf(tmpbuf, "zz%03d", i);
13699
13700 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13701 {
13702 memset(tempname, 0, sizeof(char)*64);
13703 sprintf(tempname, "e%03d", i);
13704 }
13705 }
13706
13707
6/6
✓ Branch 0 taken 17169 times.
✓ Branch 1 taken 32495 times.
✓ Branch 2 taken 16296 times.
✓ Branch 3 taken 873 times.
✓ Branch 4 taken 13443 times.
✓ Branch 5 taken 2853 times.
49664 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13708 {
13709 46811 strcpy(guy_string[i], tempname);
13710 46811 }
13711 else
13712 {
13713 2853 strcpy(guy_string[i],old_guy_string[i]);
13714 }
13715 49664 }
13716 49664 }
13717 97 }
13718 else
13719 {
13720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(keepdata)
13721 {
13722
2/2
✓ Branch 0 taken 3584 times.
✓ Branch 1 taken 7 times.
3591 for(int32_t i=0; i<eMAXGUYS; i++)
13723 {
13724 3584 sprintf(guy_string[i],"zz%03d",i);
13725 3584 }
13726
13727
2/2
✓ Branch 0 taken 1239 times.
✓ Branch 1 taken 7 times.
1246 for(int32_t i=0; i<OLDMAXGUYS; i++)
13728 {
13729 1239 strcpy(guy_string[i],old_guy_string[i]);
13730 1239 }
13731 7 }
13732 }
13733
13734
13735 //finally... section data
13736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
13737 {
13738 104 init_guys(guyversion); //using default data for now...
13739
13740 // Goriya guy fix
13741
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13742 {
13743
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
7 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13744 {
13745 5 guysbuf[gGORIYA].tile=130;
13746 5 guysbuf[gGORIYA].e_tile=130;
13747 5 }
13748 7 }
13749 104 }
13750
13751
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(Header->zelda_version < 0x193)
13752 {
13753
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_bit(deprecated_rules,46))
13754 {
13755 guysbuf[eDODONGO].cset=14;
13756 guysbuf[eDODONGO].bosspal=spDIG;
13757 }
13758 2 }
13759 // Not sure when this first changed, but it's necessary for 2.10, at least
13760 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13761 //2.10 Fixes
13762
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13763 {
13764 7 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13765 7 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13766 7 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13767 7 guysbuf[eCENT1].misc3 = 1;
13768 7 guysbuf[eCENT2].misc3 = 1;
13769 7 }
13770
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13771 {
13772 104 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13773 104 }
13774
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(Header->zelda_version <= 0x210)
13775 {
13776 7 guysbuf[eGLEEOK1F].misc6 = 16;
13777 7 guysbuf[eGLEEOK2F].misc6 = 16;
13778 7 guysbuf[eGLEEOK3F].misc6 = 16;
13779 7 guysbuf[eGLEEOK4F].misc6 = 16;
13780
13781 7 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13782 7 guysbuf[eBATROBE].misc4 = 1;
13783 //guysbuf[eSUMMONER].misc4 = 1;
13784 7 guysbuf[eWWIZ].misc4 = 1;
13785 7 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13786 7 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13787 7 }
13788
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(Header->zelda_version == 0x190)
13789 {
13790 2 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13791 2 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13792 2 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13793 2 }
13794
13795 // The versions here may not be correct
13796 // zelda_version>=0x211 handled at guyversion<24
13797
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version <= 0x190)
13798 {
13799 2 guysbuf[eCENT1].misc3 = 0;
13800 2 guysbuf[eCENT2].misc3 = 0;
13801 2 guysbuf[eMOLDORM].misc2 = 0;
13802 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13803 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13804 2 }
13805
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 else if(Header->zelda_version <= 0x210)
13806 {
13807 5 guysbuf[eCENT1].misc3 = 1;
13808 5 guysbuf[eCENT2].misc3 = 1;
13809 5 guysbuf[eMOLDORM].misc2 = 0;
13810 5 }
13811
13812
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13813 {
13814 7 guysbuf[eKEESE1].misc16 = 120;
13815 7 guysbuf[eKEESE2].misc16 = 120;
13816 7 guysbuf[eKEESE3].misc16 = 120;
13817 7 guysbuf[eKEESETRIB].misc16 = 120;
13818 7 guysbuf[eKEESE1].misc17 = 16;
13819 7 guysbuf[eKEESE2].misc17 = 16;
13820 7 guysbuf[eKEESE3].misc17 = 16;
13821 7 guysbuf[eKEESETRIB].misc17 = 16;
13822
13823 7 guysbuf[ePEAHAT].misc16 = 80;
13824 7 guysbuf[ePEAHAT].misc17 = 16;
13825
13826 7 guysbuf[eGHINI2].misc16 = 120;
13827 7 guysbuf[eGHINI2].misc17 = 10;
13828
13829 7 }
13830
13831
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(guyversion<=2)
13832 {
13833 7 return readherosprites2(f, guyversion==2?0:-1, 0, keepdata);
13834 }
13835
13836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(guyversion > 3)
13837 {
13838 guydata tempguy;
13839
13840
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 97 times.
49761 for(int32_t i=0; i<MAXGUYS; i++)
13841 {
13842
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
49664 if(guyversion < 23 && keepdata) // May 2012 : 512 max enemies
13843 {
13844 if(i >= OLDBETAMAXGUYS)
13845 {
13846 memset(&guysbuf[i], 0, sizeof(guydata));
13847 continue;
13848 }
13849 }
13850
13851 49664 memset(&tempguy, 0, sizeof(guydata));
13852
13853
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.flags),f,keepdata))
13854 {
13855 return qe_invalid;
13856 }
13857
13858
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.flags2),f,keepdata))
13859 {
13860 return qe_invalid;
13861 }
13862
13863
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion >= 36 ) //expanded tiles
13864 {
13865
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.tile),f,keepdata))
13866 {
13867 return qe_invalid;
13868 }
13869 11776 }
13870 else
13871 {
13872
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.tile),f,keepdata))
13873 {
13874 return qe_invalid;
13875 }
13876 }
13877
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.width),f,keepdata))
13878 {
13879 return qe_invalid;
13880 }
13881
13882
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.height),f,keepdata))
13883 {
13884 return qe_invalid;
13885 }
13886
13887
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion >= 36 ) //expanded tiles
13888 {
13889
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.s_tile),f,keepdata))
13890 {
13891 return qe_invalid;
13892 }
13893 11776 }
13894 else
13895 {
13896
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.s_tile),f,keepdata))
13897 {
13898 return qe_invalid;
13899 }
13900 }
13901
13902
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.s_width),f,keepdata))
13903 {
13904 return qe_invalid;
13905 }
13906
13907
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.s_height),f,keepdata))
13908 {
13909 return qe_invalid;
13910 }
13911
13912
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion >= 36 ) //expanded tiles
13913 {
13914
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.e_tile),f,keepdata))
13915 {
13916 return qe_invalid;
13917 }
13918 11776 }
13919 else
13920 {
13921
1/2
✓ Branch 0 taken 37888 times.
✗ Branch 1 not taken.
37888 if(!p_igetw(&(tempguy.e_tile),f,keepdata))
13922 {
13923 return qe_invalid;
13924 }
13925 }
13926
13927
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.e_width),f,keepdata))
13928 {
13929 return qe_invalid;
13930 }
13931
13932
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.e_height),f,keepdata))
13933 {
13934 return qe_invalid;
13935 }
13936
13937
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.hp),f,keepdata))
13938 {
13939 return qe_invalid;
13940 }
13941
13942
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.family),f,keepdata))
13943 {
13944 return qe_invalid;
13945 }
13946
13947
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
49664 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13948 {
13949 if(get_bit(quest_rules,qr_NEWENEMYTILES))
13950 {
13951 tempguy.s_tile=tempguy.e_tile+120;
13952 tempguy.s_width=tempguy.e_width;
13953 tempguy.s_height=tempguy.e_height;
13954 }
13955 else tempguy.s_tile=860;
13956 }
13957
13958
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.cset),f,keepdata))
13959 {
13960 return qe_invalid;
13961 }
13962
13963
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.anim),f,keepdata))
13964 {
13965 return qe_invalid;
13966 }
13967
13968
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.e_anim),f,keepdata))
13969 {
13970 return qe_invalid;
13971 }
13972
13973
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.frate),f,keepdata))
13974 {
13975 return qe_invalid;
13976 }
13977
13978
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.e_frate),f,keepdata))
13979 {
13980 return qe_invalid;
13981 }
13982
13983
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 13) // April 2009
13984 {
13985 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13986 {
13987 tempguy.frate *= 2;
13988 tempguy.e_frate *= 2;
13989 }
13990 }
13991
13992
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 14) // May 1 2009
13993 {
13994 if(tempguy.anim==a2FRMSLOW)
13995 {
13996 tempguy.anim=a2FRM;
13997 tempguy.frate *= 2;
13998 }
13999
14000 if(tempguy.e_anim==a2FRMSLOW)
14001 {
14002 tempguy.e_anim=a2FRM;
14003 tempguy.e_frate *= 2;
14004 }
14005
14006 if(tempguy.anim==aFLIPSLOW)
14007 {
14008 tempguy.anim=aFLIP;
14009 tempguy.frate *= 2;
14010 }
14011
14012 if(tempguy.e_anim==aFLIPSLOW)
14013 {
14014 tempguy.e_anim=aFLIP;
14015 tempguy.e_frate *= 2;
14016 }
14017
14018 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14019
14020 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14021
14022 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14023 {
14024 tempguy.anim=a4FRM4DIR;
14025 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14026 }
14027
14028 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14029 {
14030 tempguy.e_anim=a4FRM4DIR;
14031 tempguy.s_tile=(get_bit(quest_rules,qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14032 }
14033 }
14034
14035
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.dp),f,keepdata))
14036 {
14037 return qe_invalid;
14038 }
14039
14040 //correction for guy fire
14041
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 6)
14042 {
14043 if(i == gFIRE)
14044 tempguy.dp = 2;
14045 }
14046
14047
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.wdp),f,keepdata))
14048 {
14049 return qe_invalid;
14050 }
14051
14052
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.weapon),f,keepdata))
14053 {
14054 return qe_invalid;
14055 }
14056
14057 //correction for bosses using triple, "rising" fireballs
14058
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 5)
14059 {
14060 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14061 i == eGOHMA3 || i == eGOHMA4)
14062 {
14063 if(tempguy.weapon == ewFireball)
14064 tempguy.weapon = ewFireball2;
14065 }
14066 }
14067
14068
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.rate),f,keepdata))
14069 {
14070 return qe_invalid;
14071 }
14072
14073
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.hrate),f,keepdata))
14074 {
14075 return qe_invalid;
14076 }
14077
14078
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.step),f,keepdata))
14079 {
14080 return qe_invalid;
14081 }
14082
14083 // HIGHLY UNORTHODOX UPDATING THING, part 2
14084
3/4
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 48640 times.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
49664 if(fixpolsvoice && tempguy.family==eePOLSV)
14085 {
14086 tempguy.step /= 2;
14087 }
14088
14089
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.homing),f,keepdata))
14090 {
14091 return qe_invalid;
14092 }
14093
14094
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.grumble),f,keepdata))
14095 {
14096 return qe_invalid;
14097 }
14098
14099
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.item_set),f,keepdata))
14100 {
14101 return qe_invalid;
14102 }
14103
14104
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14105 {
14106
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc1),f,keepdata))
14107 {
14108 return qe_invalid;
14109 }
14110
14111
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc2),f,keepdata))
14112 {
14113 return qe_invalid;
14114 }
14115
14116
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc3),f,keepdata))
14117 {
14118 return qe_invalid;
14119 }
14120
14121
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc4),f,keepdata))
14122 {
14123 return qe_invalid;
14124 }
14125
14126
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc5),f,keepdata))
14127 {
14128 return qe_invalid;
14129 }
14130
14131
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc6),f,keepdata))
14132 {
14133 return qe_invalid;
14134 }
14135
14136
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc7),f,keepdata))
14137 {
14138 return qe_invalid;
14139 }
14140
14141
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc8),f,keepdata))
14142 {
14143 return qe_invalid;
14144 }
14145
14146
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc9),f,keepdata))
14147 {
14148 return qe_invalid;
14149 }
14150
14151
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc10),f,keepdata))
14152 {
14153 return qe_invalid;
14154 }
14155 49664 }
14156 else
14157 {
14158 int16_t tempMisc;
14159
14160 if(!p_igetw(&tempMisc,f,keepdata))
14161 {
14162 return qe_invalid;
14163 }
14164
14165 tempguy.misc1=tempMisc;
14166
14167 if(!p_igetw(&tempMisc,f,keepdata))
14168 {
14169 return qe_invalid;
14170 }
14171
14172 tempguy.misc2=tempMisc;
14173
14174 if(!p_igetw(&tempMisc,f,keepdata))
14175 {
14176 return qe_invalid;
14177 }
14178
14179 tempguy.misc3=tempMisc;
14180
14181 if(!p_igetw(&tempMisc,f,keepdata))
14182 {
14183 return qe_invalid;
14184 }
14185
14186 tempguy.misc4=tempMisc;
14187
14188 if(!p_igetw(&tempMisc,f,keepdata))
14189 {
14190 return qe_invalid;
14191 }
14192
14193 tempguy.misc5=tempMisc;
14194
14195 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14196 {
14197 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14198 tempguy.misc5 = 74;
14199 }
14200
14201 if(!p_igetw(&tempMisc,f,keepdata))
14202 {
14203 return qe_invalid;
14204 }
14205
14206 tempguy.misc6=tempMisc;
14207
14208 if(!p_igetw(&tempMisc,f,keepdata))
14209 {
14210 return qe_invalid;
14211 }
14212
14213 tempguy.misc7=tempMisc;
14214
14215 if(!p_igetw(&tempMisc,f,keepdata))
14216 {
14217 return qe_invalid;
14218 }
14219
14220 tempguy.misc8=tempMisc;
14221
14222 if(!p_igetw(&tempMisc,f,keepdata))
14223 {
14224 return qe_invalid;
14225 }
14226
14227 tempguy.misc9=tempMisc;
14228
14229 if(!p_igetw(&tempMisc,f,keepdata))
14230 {
14231 return qe_invalid;
14232 }
14233
14234 tempguy.misc10=tempMisc;
14235 }
14236
14237
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.bgsfx),f,keepdata))
14238 {
14239 return qe_invalid;
14240 }
14241
14242
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.bosspal),f,keepdata))
14243 {
14244 return qe_invalid;
14245 }
14246
14247
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetw(&(tempguy.extend),f,keepdata))
14248 {
14249 return qe_invalid;
14250 }
14251
14252 //! Enemy Defences
14253
14254 //If a 2.50 quest, use only the 2.5 defences.
14255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
49664 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14256 {
14257
2/2
✓ Branch 0 taken 943616 times.
✓ Branch 1 taken 49664 times.
993280 for(int32_t j=0; j<edefLAST; j++)
14258 {
14259
1/2
✓ Branch 0 taken 943616 times.
✗ Branch 1 not taken.
943616 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14260 {
14261 return qe_invalid;
14262 }
14263 943616 }
14264 //then copy the generic script defence to all the new script defences
14265
14266 49664 }
14267
14268
14269
14270
14271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
49664 if(guyversion >= 18)
14272 {
14273
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.hitsfx),f,keepdata))
14274 {
14275 return qe_invalid;
14276 }
14277
14278
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_getc(&(tempguy.deadsfx),f,keepdata))
14279 {
14280 return qe_invalid;
14281 }
14282 49664 }
14283
14284
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion >= 22)
14285 {
14286
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc11),f,keepdata))
14287 {
14288 return qe_invalid;
14289 }
14290
14291
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(!p_igetl(&(tempguy.misc12),f,keepdata))
14292 {
14293 return qe_invalid;
14294 }
14295 49664 }
14296 else if(guyversion >= 19)
14297 {
14298 int16_t tempMisc;
14299
14300 if(!p_igetw(&tempMisc,f,keepdata))
14301 {
14302 return qe_invalid;
14303 }
14304
14305 tempguy.misc11=tempMisc;
14306
14307 if(!p_igetw(&tempMisc,f,keepdata))
14308 {
14309 return qe_invalid;
14310 }
14311
14312 tempguy.misc12=tempMisc;
14313 }
14314
14315 //If a 2.54 or later quest, use all of the defences.
14316
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion > 24) // Add new guyversion conditional statement
14317 {
14318
2/2
✓ Branch 0 taken 259072 times.
✓ Branch 1 taken 11776 times.
270848 for(int32_t j=edefLAST; j<edefLAST255; j++)
14319 {
14320
1/2
✓ Branch 0 taken 259072 times.
✗ Branch 1 not taken.
259072 if(!p_getc(&(tempguy.defense[j]),f,keepdata))
14321 {
14322 return qe_invalid;
14323 }
14324 259072 }
14325 11776 }
14326
14327
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14328 {
14329
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14330 {
14331 378880 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14332 378880 }
14333 37888 }
14334
14335 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14336
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion > 25)
14337 {
14338
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.txsz),f,keepdata))
14339 {
14340 return qe_invalid;
14341 }
14342
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.tysz),f,keepdata))
14343 {
14344 return qe_invalid;
14345 }
14346
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hxsz),f,keepdata))
14347 {
14348 return qe_invalid;
14349 }
14350
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hysz),f,keepdata))
14351 {
14352 return qe_invalid;
14353 }
14354
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hzsz),f,keepdata))
14355 {
14356 return qe_invalid;
14357 }
14358 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14359
14360 */
14361 11776 }
14362 //More Enemy Editor vars for 2.60
14363
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion > 26)
14364 {
14365
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hxofs),f,keepdata))
14366 {
14367 return qe_invalid;
14368 }
14369
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.hyofs),f,keepdata))
14370 {
14371 return qe_invalid;
14372 }
14373
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.xofs),f,keepdata))
14374 {
14375 return qe_invalid;
14376 }
14377
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.yofs),f,keepdata))
14378 {
14379 return qe_invalid;
14380 }
14381
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.zofs),f,keepdata))
14382 {
14383 return qe_invalid;
14384 }
14385 11776 }
14386
14387
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14388 {
14389 37888 tempguy.wpnsprite = 0;
14390 37888 }
14391
14392
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion > 27)
14393 {
14394
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.wpnsprite),f,keepdata))
14395 {
14396 return qe_invalid;
14397 }
14398 11776 }
14399
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14400 {
14401 37888 tempguy.SIZEflags = 0;
14402 37888 }
14403
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion > 28)
14404 {
14405
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.SIZEflags),f,keepdata))
14406 {
14407 return qe_invalid;
14408 }
14409
14410 11776 }
14411
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14412 {
14413 37888 tempguy.frozentile = 0;
14414 37888 tempguy.frozencset = 0;
14415 37888 tempguy.frozenclock = 0;
14416
2/2
✓ Branch 0 taken 378880 times.
✓ Branch 1 taken 37888 times.
416768 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14417 37888 }
14418
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion >= 30)
14419 {
14420
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozentile),f,keepdata))
14421 {
14422 return qe_invalid;
14423 }
14424
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozencset),f,keepdata))
14425 {
14426 return qe_invalid;
14427 }
14428
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.frozenclock),f,keepdata))
14429 {
14430 return qe_invalid;
14431 }
14432
2/2
✓ Branch 0 taken 117760 times.
✓ Branch 1 taken 11776 times.
129536 for ( int32_t q = 0; q < 10; q++ ) {
14433
1/2
✓ Branch 0 taken 117760 times.
✗ Branch 1 not taken.
117760 if(!p_igetw(&(tempguy.frozenmisc[q]),f,keepdata))
14434 {
14435 return qe_invalid;
14436 }
14437 117760 }
14438
14439 11776 }
14440
14441
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion >= 34)
14442 {
14443
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.firesfx),f,keepdata))
14444 {
14445 return qe_invalid;
14446 }
14447
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc16),f,keepdata))
14448 {
14449 return qe_invalid;
14450 }
14451
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc17),f,keepdata))
14452 {
14453 return qe_invalid;
14454 }
14455
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc18),f,keepdata))
14456 {
14457 return qe_invalid;
14458 }
14459
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc19),f,keepdata))
14460 {
14461 return qe_invalid;
14462 }
14463
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc20),f,keepdata))
14464 {
14465 return qe_invalid;
14466 }
14467
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc21),f,keepdata))
14468 {
14469 return qe_invalid;
14470 }
14471
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc22),f,keepdata))
14472 {
14473 return qe_invalid;
14474 }
14475
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc23),f,keepdata))
14476 {
14477 return qe_invalid;
14478 }
14479
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc24),f,keepdata))
14480 {
14481 return qe_invalid;
14482 }
14483
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc25),f,keepdata))
14484 {
14485 return qe_invalid;
14486 }
14487
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc26),f,keepdata))
14488 {
14489 return qe_invalid;
14490 }
14491
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc27),f,keepdata))
14492 {
14493 return qe_invalid;
14494 }
14495
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc28),f,keepdata))
14496 {
14497 return qe_invalid;
14498 }
14499
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc29),f,keepdata))
14500 {
14501 return qe_invalid;
14502 }
14503
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc30),f,keepdata))
14504 {
14505 return qe_invalid;
14506 }
14507
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc31),f,keepdata))
14508 {
14509 return qe_invalid;
14510 }
14511
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc32),f,keepdata))
14512 {
14513 return qe_invalid;
14514 }
14515
14516
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 11776 times.
388608 for ( int32_t q = 0; q < 32; q++ ) {
14517
1/2
✓ Branch 0 taken 376832 times.
✗ Branch 1 not taken.
376832 if(!p_igetl(&(tempguy.movement[q]),f,keepdata))
14518 {
14519 return qe_invalid;
14520 }
14521 376832 }
14522
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 11776 times.
388608 for ( int32_t q = 0; q < 32; q++ ) {
14523
1/2
✓ Branch 0 taken 376832 times.
✗ Branch 1 not taken.
376832 if(!p_igetl(&(tempguy.new_weapon[q]),f,keepdata))
14524 {
14525 return qe_invalid;
14526 }
14527 376832 }
14528
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.script),f,keepdata))
14529 {
14530 return qe_invalid;
14531 }
14532 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14533
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14534 {
14535
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&(tempguy.initD[q]),f,keepdata))
14536 {
14537 return qe_invalid;
14538 }
14539 94208 }
14540
2/2
✓ Branch 0 taken 23552 times.
✓ Branch 1 taken 11776 times.
35328 for ( int32_t q = 0; q < 2; q++ )
14541 {
14542
1/2
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
23552 if(!p_igetl(&(tempguy.initA[q]),f,keepdata))
14543 {
14544 return qe_invalid;
14545 }
14546 23552 }
14547
14548 11776 }
14549
14550
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion >= 37)
14551 {
14552
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.editorflags),f,keepdata))
14553 {
14554 return qe_invalid;
14555 }
14556 11776 }
14557
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14558
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if(guyversion >= 38)
14559 {
14560
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc13),f,keepdata))
14561 {
14562 return qe_invalid;
14563 }
14564
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc14),f,keepdata))
14565 {
14566 return qe_invalid;
14567 }
14568
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetl(&(tempguy.misc15),f,keepdata))
14569 {
14570 return qe_invalid;
14571 }
14572
14573 11776 }
14574
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion < 38 )
14575 {
14576 37888 tempguy.misc13 = 0;
14577 37888 tempguy.misc14 = 0;
14578 37888 tempguy.misc15 = 0;
14579 37888 }
14580
14581
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if ( guyversion >= 39 )
14582 {
14583
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14584 {
14585
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
14586 {
14587
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&(tempguy.initD_label[q][w]),f,keepdata))
14588 {
14589 return qe_invalid;
14590 }
14591 6123520 }
14592
2/2
✓ Branch 0 taken 6123520 times.
✓ Branch 1 taken 94208 times.
6217728 for ( int32_t w = 0; w < 65; w++ )
14593 {
14594
1/2
✓ Branch 0 taken 6123520 times.
✗ Branch 1 not taken.
6123520 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f,keepdata))
14595 {
14596 return qe_invalid;
14597 }
14598 6123520 }
14599 94208 }
14600
14601
14602 11776 }
14603
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion < 39 ) //apply old InitD strings to both
14604 {
14605
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ )
14606 {
14607 303104 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14608 303104 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14609 303104 }
14610 37888 }
14611
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if ( guyversion >= 40 )
14612 {
14613
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_igetw(&(tempguy.weaponscript),f,keepdata))
14614 {
14615 return qe_invalid;
14616 }
14617 11776 }
14618
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if ( guyversion < 40 )
14619 {
14620 37888 tempguy.weaponscript = 0;
14621 37888 }
14622 //eweapon script InitD
14623
2/2
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
49664 if ( guyversion >= 41 )
14624 {
14625
2/2
✓ Branch 0 taken 94208 times.
✓ Branch 1 taken 11776 times.
105984 for ( int32_t q = 0; q < 8; q++ )
14626 {
14627
1/2
✓ Branch 0 taken 94208 times.
✗ Branch 1 not taken.
94208 if(!p_igetl(&(tempguy.weap_initiald[q]),f,keepdata))
14628 {
14629 return qe_invalid;
14630 }
14631 94208 }
14632
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if ( guy_cversion < 4 )
14633 {
14634 if ( tempguy.family == eeKEESE )
14635 {
14636
14637 if ( !tempguy.misc1 )
14638 {
14639 tempguy.misc16 = 120;
14640 tempguy.misc17 = 16;
14641
14642 }
14643 }
14644 if ( tempguy.family == eePEAHAT )
14645 {
14646 tempguy.misc16 = 80;
14647 tempguy.misc17 = 16;
14648 }
14649
14650 if ( tempguy.family == eeGHINI )
14651 {
14652 tempguy.misc16 = 120;
14653 tempguy.misc17 = 10;
14654 }
14655
14656 }
14657 11776 }
14658
14659
14660
14661 //default weapon sprites (quest version < 2.54)
14662 //port over old defaults -Z
14663
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 32)
14664 {
14665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.wpnsprite <= 0 )
14666 {
14667
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14668 {
14669 case wNone:
14670 31522 tempguy.wpnsprite = 0; break;
14671
14672 case wSword:
14673 case wBeam:
14674 case wBrang:
14675 case wBomb:
14676 case wSBomb:
14677 case wLitBomb:
14678 case wLitSBomb:
14679 case wArrow:
14680 case wFire:
14681 case wWhistle:
14682 case wBait:
14683 case wWand:
14684 case wMagic:
14685 case wCatching:
14686 case wWind:
14687 case wRefMagic:
14688 case wRefFireball:
14689 case wRefRock:
14690 case wHammer:
14691 case wHookshot:
14692 case wHSHandle:
14693 case wHSChain:
14694 case wSSparkle:
14695 case wFSparkle:
14696 case wSmack:
14697 case wPhantom:
14698 case wCByrna:
14699 case wRefBeam:
14700 case wStomp:
14701 case lwMax:
14702 case wScript1:
14703 case wScript2:
14704 case wScript3:
14705 case wScript4:
14706 case wScript5:
14707 case wScript6:
14708 case wScript7:
14709 case wScript8:
14710 case wScript9:
14711 case wScript10:
14712 case wIce:
14713 //Cannot use any of these weapons yet.
14714 tempguy.wpnsprite = -1;
14715 break;
14716
14717 case wEnemyWeapons:
14718 1257 case ewFireball: tempguy.wpnsprite = 17; break;
14719
14720 289 case ewArrow: tempguy.wpnsprite = 19; break;
14721 306 case ewBrang: tempguy.wpnsprite = 4; break;
14722 908 case ewSword: tempguy.wpnsprite = 20; break;
14723 472 case ewRock: tempguy.wpnsprite = 18; break;
14724 873 case ewMagic: tempguy.wpnsprite = 21; break;
14725 77 case ewBomb: tempguy.wpnsprite = 78; break;
14726 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14727 130 case ewLitBomb: tempguy.wpnsprite = 76; break;
14728 18 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14729 355 case ewFireTrail: tempguy.wpnsprite = 80; break;
14730 734 case ewFlame: tempguy.wpnsprite = 35; break;
14731 104 case ewWind: tempguy.wpnsprite = 36; break;
14732 74 case ewFlame2: tempguy.wpnsprite = 81; break;
14733 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14734 case ewIce: tempguy.wpnsprite = 83; break;
14735 751 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14736
14737
14738 default: break; //No assign.
14739 }
14740 37888 }
14741 37888 }
14742
14743 //default weapon fire sound (quest version < 2.54)
14744 //port over old defaults and zero new data. -Z
14745
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 34)
14746 {
14747
2/2
✓ Branch 0 taken 1212416 times.
✓ Branch 1 taken 37888 times.
1250304 for ( int32_t q = 0; q < 32; q++ )
14748 {
14749 1212416 tempguy.movement[q] = 0;
14750 1212416 tempguy.new_weapon[q] = 0;
14751
14752 1212416 }
14753
14754 //NPC Script attributes.
14755 37888 tempguy.script = 0; //No scripted enemies existed. -Z
14756
2/2
✓ Branch 0 taken 303104 times.
✓ Branch 1 taken 37888 times.
340992 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14757
2/2
✓ Branch 0 taken 75776 times.
✓ Branch 1 taken 37888 times.
113664 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14758
14759 37888 tempguy.misc16 = 0;
14760 37888 tempguy.misc17 = 0;
14761 37888 tempguy.misc18 = 0;
14762 37888 tempguy.misc19 = 0;
14763 37888 tempguy.misc20 = 0;
14764 37888 tempguy.misc21 = 0;
14765 37888 tempguy.misc22 = 0;
14766 37888 tempguy.misc23 = 0;
14767 37888 tempguy.misc24 = 0;
14768 37888 tempguy.misc25 = 0;
14769 37888 tempguy.misc26 = 0;
14770 37888 tempguy.misc27 = 0;
14771 37888 tempguy.misc28 = 0;
14772 37888 tempguy.misc29 = 0;
14773 37888 tempguy.misc30 = 0;
14774 37888 tempguy.misc31 = 0;
14775 37888 tempguy.misc32 = 0;
14776
14777 //old default sounds
14778
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37888 times.
37888 if ( tempguy.firesfx <= 0 )
14779 {
14780
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1257 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31522 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 306 times.
✓ Branch 6 taken 908 times.
✓ Branch 7 taken 472 times.
✓ Branch 8 taken 873 times.
✓ Branch 9 taken 77 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 130 times.
✓ Branch 12 taken 18 times.
✓ Branch 13 taken 355 times.
✓ Branch 14 taken 734 times.
✓ Branch 15 taken 104 times.
✓ Branch 16 taken 74 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 751 times.
37888 switch(tempguy.weapon)
14781 {
14782 case wNone:
14783 31522 tempguy.firesfx = 0; break;
14784
14785 case wSword:
14786 case wBeam:
14787 case wBrang:
14788 case wBomb:
14789 case wSBomb:
14790 case wLitBomb:
14791 case wLitSBomb:
14792 case wArrow:
14793 case wFire:
14794 case wWhistle:
14795 case wBait:
14796 case wWand:
14797 case wMagic:
14798 case wCatching:
14799 case wWind:
14800 case wRefMagic:
14801 case wRefFireball:
14802 case wRefRock:
14803 case wHammer:
14804 case wHookshot:
14805 case wHSHandle:
14806 case wHSChain:
14807 case wSSparkle:
14808 case wFSparkle:
14809 case wSmack:
14810 case wPhantom:
14811 case wCByrna:
14812 case wRefBeam:
14813 case wStomp:
14814 case lwMax:
14815 case wScript1:
14816 case wScript2:
14817 case wScript3:
14818 case wScript4:
14819 case wScript5:
14820 case wScript6:
14821 case wScript7:
14822 case wScript8:
14823 case wScript9:
14824 case wScript10:
14825 case wIce:
14826 //Cannot use any of these weapons yet.
14827 tempguy.firesfx = -1;
14828 break;
14829
14830 case wEnemyWeapons:
14831 1257 case ewFireball: tempguy.firesfx = 40; break;
14832
14833 289 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14834 306 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14835 908 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14836 472 case ewRock: tempguy.firesfx = 51; break;
14837 873 case ewMagic: tempguy.firesfx = 32; break;
14838 77 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14839 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14840 130 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14841 18 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14842 355 case ewFireTrail: tempguy.firesfx = 13; break;
14843 734 case ewFlame: tempguy.firesfx = 13; break;
14844 104 case ewWind: tempguy.firesfx = 32; break;
14845 74 case ewFlame2: tempguy.firesfx = 13; break;
14846 case ewFlame2Trail: tempguy.firesfx = 13; break;
14847 case ewIce: tempguy.firesfx = 44; break;
14848 751 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14849
14850 //what about special attacks (e.g. summoning == 56)
14851 default: break; //No assign.
14852 }
14853 37888 }
14854 37888 }
14855
14856 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14857
4/6
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
✓ Branch 2 taken 11776 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11776 times.
49664 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14858 {
14859
2/2
✓ Branch 0 taken 2994 times.
✓ Branch 1 taken 34894 times.
37888 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14860 37888 }
14861 //Keese and bat halt rates.
14862
3/4
✓ Branch 0 taken 37888 times.
✓ Branch 1 taken 11776 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 37888 times.
49664 if ( guyversion < 42 && guy_cversion < 4 )
14863 {
14864
14865
2/2
✓ Branch 0 taken 37378 times.
✓ Branch 1 taken 510 times.
37888 if ( tempguy.family == eeKEESE )
14866 {
14867
14868
2/2
✓ Branch 0 taken 196 times.
✓ Branch 1 taken 314 times.
510 if ( !tempguy.misc1 )
14869 {
14870 314 tempguy.misc16 = 120;
14871 314 tempguy.misc17 = 16;
14872
14873 314 }
14874 510 }
14875
2/2
✓ Branch 0 taken 37726 times.
✓ Branch 1 taken 162 times.
37888 if ( tempguy.family == eePEAHAT )
14876 {
14877 162 tempguy.misc16 = 80;
14878 162 tempguy.misc17 = 16;
14879 162 }
14880
2/2
✓ Branch 0 taken 37814 times.
✓ Branch 1 taken 74 times.
37888 if ( tempguy.family == eeGHINI )
14881 {
14882 74 tempguy.misc16 = 120;
14883 74 tempguy.misc17 = 10;
14884 74 }
14885
14886
14887 37888 }
14888
14889
14890 //miscellaneous other corrections
14891 //fix the mirror wizzrobe -DD
14892
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 7)
14893 {
14894 if(i == eMWIZ)
14895 {
14896 tempguy.misc2 = 0;
14897 tempguy.misc4 = 1;
14898 }
14899 }
14900
14901
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 8)
14902 {
14903 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14904 {
14905 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14906 tempguy.misc5 = 4; //neck length in segments
14907 tempguy.misc6 = 8; //neck offset from first body tile
14908 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14909 tempguy.misc8 = 168; //head offset from first body tile
14910 tempguy.misc9 = 228; //flying head offset from first body tile
14911
14912 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14913 {
14914 tempguy.misc6 += 10; //neck offset from first body tile
14915 tempguy.misc8 -= 12; //head offset from first body tile
14916 }
14917 }
14918 }
14919
14920
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14921 {
14922 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14923 tempguy.bosspal = spDIG;
14924 }
14925
14926
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 11) // December 2007 - Spinning Tile fix
14927 {
14928 if(tempguy.family==eeSPINTILE)
14929 {
14930 tempguy.flags |= guy_superman;
14931 tempguy.item_set = 0; // Don't drop items
14932 tempguy.step = 300;
14933 }
14934 }
14935
14936
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14937 {
14938 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14939 {
14940 if(tempguy.family==eeROPE)
14941 {
14942 tempguy.flags2 &= ~guy_flashing;
14943 }
14944 }
14945
14946 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14947 {
14948 if(tempguy.family==eeBUBBLE)
14949 {
14950 tempguy.flags2 &= ~guy_flashing;
14951 }
14952 }
14953
14954 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14955 {
14956 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14957 {
14958 tempguy.flags2 |= guy_blinking;
14959 }
14960
14961 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14962 {
14963 tempguy.flags2 |= guy_transparent;
14964 }
14965 }
14966 }
14967
14968
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14969 {
14970 if(i==gFIRE)
14971 {
14972 tempguy.e_anim = aFLIP;
14973 tempguy.e_frate = 24;
14974 }
14975
14976 if(i==gFAIRY)
14977 {
14978 tempguy.e_anim = a2FRM;
14979 tempguy.e_frate = 16;
14980 }
14981 }
14982
14983
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14984 {
14985 if(i==0) Z_message("Updating guys to version 16...\n");
14986
14987 update_guy_1(&tempguy);
14988
14989 if(i==eMPOLSV)
14990 {
14991 tempguy.defense[edefARROW] = edCHINK;
14992 tempguy.defense[edefMAGIC] = ed1HKO;
14993 tempguy.defense[edefREFMAGIC] = ed1HKO;
14994 }
14995 }
14996
14997
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 17) // December 2009
14998 {
14999 if(tempguy.family==eePROJECTILE)
15000 {
15001 tempguy.misc1 = 0;
15002 }
15003 }
15004
15005
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 18) // January 2010
15006 {
15007 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15008 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15009
15010 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15011 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15012
15013 if(tempguy.family == eeAQUA)
15014 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15015 else if(tempguy.family == eeMANHAN)
15016 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15017 else if(tempguy.family==eePATRA)
15018 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15019 else if(tempguy.family==eeGHOMA)
15020 {
15021 for(int32_t j=0; j<edefLAST; j++)
15022 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15023
15024 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15025
15026 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15027
15028 tempguy.misc1--;
15029 }
15030 else if(tempguy.family == eeGLEEOK)
15031 {
15032 for(int32_t j=0; j<edefLAST; j++)
15033 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15034
15035 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15036 }
15037 else if(tempguy.family == eeARMOS)
15038 {
15039 tempguy.family=eeWALK;
15040 tempguy.hrate = 0;
15041 tempguy.misc10 = tempguy.misc1;
15042 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15043 tempguy.misc9 = e9tARMOS;
15044 }
15045 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15046 {
15047 tempguy.family=eeWALK;
15048 tempguy.hrate = 0;
15049 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15050 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15051 }
15052
15053 // Spawn animation flags
15054 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15055 tempguy.flags |= guy_fadeflicker;
15056 else
15057 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15058 }
15059
15060
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 20) // April 2010
15061 {
15062 if(tempguy.family == eeTRAP)
15063 {
15064 tempguy.misc2 = tempguy.misc10;
15065
15066 if(tempguy.misc10>=1)
15067 {
15068 tempguy.misc1++;
15069 }
15070
15071 tempguy.misc10 = 0;
15072 }
15073
15074 // Bomb Blast fix
15075 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15076 tempguy.weapon = ewLitBomb;
15077 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15078 tempguy.weapon = ewLitSBomb;
15079 }
15080
15081
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 21) // September 2011
15082 {
15083 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15084 {
15085 if(tempguy.family == eeKEESETRIB)
15086 {
15087 tempguy.family = eeKEESE;
15088 tempguy.misc2 = e2tKEESETRIB;
15089 tempguy.misc1 = 0;
15090 }
15091
15092 tempguy.rate = 2;
15093 tempguy.hrate = 8;
15094 tempguy.homing = 0;
15095 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15096 }
15097 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15098 {
15099 if(tempguy.family == eePEAHAT)
15100 {
15101 tempguy.rate = 4;
15102 tempguy.step = 62;
15103 }
15104 else
15105 tempguy.step = 25;
15106
15107 tempguy.hrate = 8;
15108 tempguy.homing = 0;
15109 }
15110 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15111 {
15112 if(tempguy.family == eeMANHAN)
15113 tempguy.step=50;
15114
15115 tempguy.hrate = 16;
15116 tempguy.homing = 0;
15117 }
15118 else if(tempguy.family == eeGLEEOK)
15119 {
15120 tempguy.rate = 2;
15121 tempguy.homing = 0;
15122 tempguy.hrate = 9;
15123 tempguy.step=89;
15124 }
15125 else if(tempguy.family == eeGHINI)
15126 {
15127 tempguy.rate = 4;
15128 tempguy.hrate = 12;
15129 tempguy.step=62;
15130 tempguy.homing = 0;
15131 }
15132
15133 // Bigdig random rate fix
15134 if(tempguy.family==eeDIG && tempguy.misc10==1)
15135 {
15136 tempguy.rate = 2;
15137 }
15138 }
15139
15140
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if(guyversion < 24) // November 2012
15141 {
15142 if(tempguy.family==eeLANM)
15143 tempguy.misc3 = 1;
15144 else if(tempguy.family==eeMOLD)
15145 tempguy.misc2 = 0;
15146 }
15147
15148
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15149 {
15150
2/2
✓ Branch 0 taken 647 times.
✓ Branch 1 taken 37241 times.
37888 if(tempguy.family!=eeDIG)
15151 {
15152 37241 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15153 37241 }
15154
15155 37888 }
15156 // does not seem to solve the issue!
15157
1/2
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
49664 if ( Header->zelda_version <= 0x210 )
15158 {
15159 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15160 if ( tempguy.family == eeDONGO )
15161 {
15162 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15163 }
15164 }
15165
15166
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion >= 42)
15167 {
15168
2/2
✓ Branch 0 taken 10752 times.
✓ Branch 1 taken 1024 times.
11776 if(guyversion >= 47)
15169 {
15170
1/2
✓ Branch 0 taken 10752 times.
✗ Branch 1 not taken.
10752 if(!p_igetl(&(tempguy.moveflags),f,keepdata))
15171 {
15172 return qe_invalid;
15173 }
15174 10752 }
15175 else
15176 {
15177 byte fl;
15178
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f,keepdata))
15179 {
15180 return qe_invalid;
15181 }
15182 1024 tempguy.moveflags = fl;
15183 }
15184 11776 }
15185 else
15186 {
15187
7/8
✓ Branch 0 taken 142 times.
✓ Branch 1 taken 29895 times.
✓ Branch 2 taken 1177 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 507 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 234 times.
✓ Branch 7 taken 5662 times.
37888 switch(tempguy.family)
15188 {
15189 //No gravity; floats over pits
15190 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15191 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15192 //Special (bosses, etc)
15193 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15194 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15195 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15196 29895 tempguy.moveflags = FLAG_CAN_PITWALK;
15197 29895 break;
15198 //No gravity, but falls in pits
15199 case eeLEV:
15200 507 tempguy.moveflags = FLAG_CAN_PITFALL;
15201 507 break;
15202 //Bosses that respect pits
15203 case eeDONGO:
15204 271 tempguy.moveflags = FLAG_OBEYS_GRAV;
15205 271 break;
15206 case eeLANM:
15207 234 tempguy.moveflags = 0;
15208 234 break;
15209 //Gravity, floats over pits
15210 case eeWIZZ: case eeWALLM: case eeGHINI:
15211 1177 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15212 1177 break;
15213 //Gravity and falls in pits
15214 case eeWALK:
15215
4/4
✓ Branch 0 taken 5349 times.
✓ Branch 1 taken 313 times.
✓ Branch 2 taken 275 times.
✓ Branch 3 taken 5074 times.
5662 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15216 588 break;
15217 [[fallthrough]];
15218 case eeOTHER:
15219 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15220 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15221 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15222 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15223 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15224 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15225 5216 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15226 5216 }
15227 }
15228
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 43)
15229 {
15230
2/2
✓ Branch 0 taken 31072 times.
✓ Branch 1 taken 6816 times.
37888 switch(tempguy.family)
15231 {
15232 //No gravity; floats over pits
15233 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15234 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15235 //Special (bosses, etc)
15236 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15237 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15238 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15239 case eeWIZZ: case eeWALLM: case eeGHINI:
15240 //Gravity, floats over pits
15241 31072 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15242 31072 break;
15243 }
15244 37888 }
15245
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if (guyversion < 44)
15246 {
15247
2/2
✓ Branch 0 taken 37527 times.
✓ Branch 1 taken 361 times.
37888 if ( tempguy.family == eeGHOMA )
15248 {
15249 361 tempguy.flags |= guy_fadeinstant;
15250 361 }
15251 37888 }
15252
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if (guyversion > 44)
15253 {
15254
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_shadow),f,keepdata))
15255 {
15256 return qe_invalid;
15257 }
15258
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_death),f,keepdata))
15259 {
15260 return qe_invalid;
15261 }
15262
1/2
✓ Branch 0 taken 11776 times.
✗ Branch 1 not taken.
11776 if(!p_getc(&(tempguy.spr_spawn),f,keepdata))
15263 {
15264 return qe_invalid;
15265 }
15266 11776 }
15267 else
15268 {
15269
2/2
✓ Branch 0 taken 37740 times.
✓ Branch 1 taken 148 times.
37888 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15270 37888 tempguy.spr_death = iwDeath;
15271 37888 tempguy.spr_spawn = iwSpawn;
15272 }
15273
15274
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 37888 times.
49664 if(guyversion < 46)
15275 {
15276
4/4
✓ Branch 0 taken 5662 times.
✓ Branch 1 taken 32226 times.
✓ Branch 2 taken 5349 times.
✓ Branch 3 taken 313 times.
37888 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15277 {
15278 313 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15279 313 }
15280 37888 }
15281
15282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 49664 times.
49664 if(keepdata)
15283 {
15284 49664 guysbuf[i] = tempguy;
15285 49664 }
15286 49664 }
15287 97 }
15288
15289 97 return 0;
15290 104 }
15291
15292 void update_guy_1(guydata *tempguy) // November 2009
15293 {
15294 bool doesntcount = false;
15295 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15296
15297 switch(tempguy->family)
15298 {
15299 case 1: //eeWALK
15300 switch(tempguy->misc10)
15301 {
15302 case 0: //Stalfos
15303 if(tempguy->misc1==1) // Fires four projectiles at once
15304 tempguy->misc1=4;
15305
15306 break;
15307
15308 case 1: //Darknut
15309 goto darknuts;
15310 break;
15311 }
15312
15313 tempguy->misc10 = 0;
15314 break;
15315
15316 case 2: //eeSHOOT
15317 tempguy->family = eeWALK;
15318
15319 switch(tempguy->misc10)
15320 {
15321 case 0: //Octorok
15322 if(tempguy->misc1==1||tempguy->misc1==2)
15323 {
15324 tempguy->misc1=e1tFIREOCTO;
15325 tempguy->misc2=e2tFIREOCTO;
15326 }
15327 else tempguy->misc1 = 0;
15328
15329 tempguy->misc6=tempguy->misc4;
15330 tempguy->misc4=tempguy->misc3;
15331 tempguy->misc3=0;
15332 break;
15333
15334 case 1: // Moblin
15335 tempguy->misc1 = 0;
15336 break;
15337
15338 case 2: //Lynel
15339 tempguy->misc6=tempguy->misc1+1;
15340 tempguy->misc1=0;
15341 break;
15342
15343 case 3: //Stalfos 2
15344 if(tempguy->misc1==1) // Fires four projectiles at once
15345 tempguy->misc1=e1t4SHOTS;
15346 else tempguy->misc1 = 0;
15347
15348 break;
15349
15350 case 4: //Darknut 5
15351 darknuts:
15352 tempguy->defense[edefFIRE] = edIGNORE;
15353 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15354 tempguy->defense[edefHOOKSHOT] = 0;
15355 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15356 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15357
15358 if(tempguy->misc1==1)
15359 tempguy->misc1=2;
15360 else if(tempguy->misc1==2)
15361 {
15362 tempguy->misc4=tempguy->misc3;
15363 tempguy->misc3=tempguy->misc2;
15364 tempguy->misc2=e2tSPLIT;
15365 tempguy->misc1 = 0;
15366 }
15367 else tempguy->misc1 = 0;
15368
15369 tempguy->flags |= inv_front;
15370
15371 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15372 tempguy->flags |= guy_bkshield;
15373
15374 break;
15375 }
15376
15377 tempguy->misc10 = 0;
15378 break;
15379
15380 /*
15381 case 9: //eeARMOS
15382 tempguy->family = eeWALK;
15383 break;
15384 */
15385 case 11: //eeGEL
15386 case 33: //eeGELTRIB
15387 if(tempguy->family==33)
15388 {
15389 tempguy->misc4 = 1;
15390
15391 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15392 tempguy->misc3 = tempguy->misc2;
15393
15394 tempguy->misc2 = e2tTRIBBLE;
15395 }
15396 else
15397 {
15398 tempguy->misc4 = 0;
15399 tempguy->misc3 = 0;
15400 tempguy->misc2 = 0;
15401 }
15402
15403 tempguy->family = eeWALK;
15404
15405 if(tempguy->misc1)
15406 {
15407 tempguy->misc1=1;
15408 tempguy->weapon = ewFireTrail;
15409 }
15410
15411 break;
15412
15413 case 34: //eeZOLTRIB
15414 case 12: //eeZOL
15415 tempguy->misc4=tempguy->misc3;
15416 tempguy->misc3=tempguy->misc2;
15417 tempguy->family = eeWALK;
15418 tempguy->misc2=e2tSPLITHIT;
15419
15420 if(tempguy->misc1)
15421 {
15422 tempguy->misc1=1;
15423 tempguy->weapon = ewFireTrail;
15424 }
15425
15426 break;
15427
15428 case 13: //eeROPE
15429 tempguy->family = eeWALK;
15430 tempguy->misc9 = e9tROPE;
15431
15432 if(tempguy->misc1)
15433 {
15434 tempguy->misc4 = tempguy->misc3;
15435 tempguy->misc3 = tempguy->misc2;
15436 tempguy->misc2 = e2tBOMBCHU;
15437 }
15438
15439 tempguy->misc1 = 0;
15440 break;
15441
15442 case 14: //eeGORIYA
15443 tempguy->family = eeWALK;
15444
15445 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15446
15447 break;
15448
15449 case 17: //eeBUBBLE
15450 tempguy->family = eeWALK;
15451 tempguy->misc8 = tempguy->misc2;
15452 tempguy->misc7 = tempguy->misc1 + 1;
15453 tempguy->misc1 = tempguy->misc2 = 0;
15454
15455 //fallthrogh
15456 case eeTRAP:
15457 case eeROCK:
15458 doesntcount = true;
15459 break;
15460
15461 case 35: //eeVIRETRIB
15462 case 18: //eeVIRE
15463 tempguy->family = eeWALK;
15464 tempguy->misc4=tempguy->misc3;
15465 tempguy->misc3=tempguy->misc2;
15466 tempguy->misc2=e2tSPLITHIT;
15467 tempguy->misc9=e9tVIRE;
15468 break;
15469
15470 case 19: //eeLIKE
15471 tempguy->family = eeWALK;
15472 tempguy->misc7 = e7tEATITEMS;
15473 tempguy->misc8=95;
15474 break;
15475
15476 case 20: //eePOLSV
15477 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15478 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15479 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15480 tempguy->defense[edefARROW] = ed1HKO;
15481 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15482 tempguy->family = eeWALK;
15483 tempguy->misc9 = e9tPOLSVOICE;
15484 tempguy->rate = 4;
15485 tempguy->homing = 32;
15486 tempguy->hrate = 10;
15487 tempguy->grumble = 0;
15488 break;
15489
15490 case eeWIZZ:
15491 if(tempguy->misc4)
15492 {
15493 for(int32_t i=0; i < edefLAST; i++)
15494 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15495 }
15496 else
15497 {
15498 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15499 tempguy->defense[edefMAGIC] = edCHINK;
15500 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15501 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15502 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15503 }
15504
15505 break;
15506
15507 case eePEAHAT:
15508 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15509
15510 if(!(tempguy->flags & guy_bhit))
15511 tempguy->defense[edefBRANG] = edSTUNONLY;
15512
15513 break;
15514
15515 case eeLEV:
15516 tempguy->defense[edefSTOMP] = edCHINK;
15517 break;
15518 }
15519
15520 // Old flags
15521 if(tempguy->flags & guy_superman)
15522 {
15523 for(int32_t i = 0; i < edefLAST; i++)
15524 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15525 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15526 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15527 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15528 }
15529
15530 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15531
15532 if(doesntcount)
15533 tempguy->flags |= (guy_doesntcount);
15534 }
15535
15536
15537 165272 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15538 {
15539 byte tempbyte, padding;
15540 int32_t extras, secretcombos;
15541 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->valid),f,true))
15543 {
15544 return qe_invalid;
15545 }
15546
15547
15548
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->guy),f,true))
15549 {
15550 return qe_invalid;
15551 }
15552
15553
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15554 {
15555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3432 times.
3432 if(!p_getc(&tempbyte,f,true))
15556 {
15557 return qe_invalid;
15558 }
15559
15560 3432 temp_mapscr->str=tempbyte;
15561 3432 }
15562 else
15563 {
15564
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
161840 if(!p_igetw(&(temp_mapscr->str),f,true))
15565 {
15566 return qe_invalid;
15567 }
15568 }
15569
15570
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->room),f,true))
15571 {
15572 return qe_invalid;
15573 }
15574
15575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->item),f,true))
15576 {
15577 return qe_invalid;
15578 }
15579
15580
3/6
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 133960 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15581 {
15582 31312 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15583 31312 }
15584 else
15585 {
15586
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->hasitem),f,true))
15587 return qe_invalid;
15588 }
15589
15590
2/4
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
165272 if((Header->zelda_version < 0x192)||
15591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
161840 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15592 {
15593
1/2
✓ Branch 0 taken 3432 times.
✗ Branch 1 not taken.
3432 if(!p_getc(&tempbyte,f,true))
15594 {
15595 return qe_invalid;
15596 }
15597 3432 }
15598
15599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f,true))
15600 {
15601 return qe_invalid;
15602 }
15603
15604
2/2
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
165272 if(Header->zelda_version < 0x193)
15605 {
15606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3432 times.
3432 if(!p_getc(&tempbyte,f,true))
15607 {
15608 return qe_invalid;
15609 }
15610 3432 }
15611
15612
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15613 {
15614
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15615 {
15616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
15617 {
15618 return qe_invalid;
15619 }
15620 401880 }
15621 133960 }
15622 else
15623 {
15624 31312 temp_mapscr->tilewarptype[1]=0;
15625 31312 temp_mapscr->tilewarptype[2]=0;
15626 31312 temp_mapscr->tilewarptype[3]=0;
15627 }
15628
15629
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15630 {
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
161840 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
15632 {
15633 return qe_invalid;
15634 }
15635 161840 }
15636
15637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f,true))
15638 {
15639 return qe_invalid;
15640 }
15641
15642 165272 temp_mapscr->warpreturnx[1]=0;
15643 165272 temp_mapscr->warpreturnx[2]=0;
15644 165272 temp_mapscr->warpreturnx[3]=0;
15645
15646
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15647 {
15648
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15649 {
15650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
15651 {
15652 return qe_invalid;
15653 }
15654 401880 }
15655 133960 }
15656
15657
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->warpreturny[0]),f,true))
15658 {
15659 return qe_invalid;
15660 }
15661
15662 165272 temp_mapscr->warpreturny[1]=0;
15663 165272 temp_mapscr->warpreturny[2]=0;
15664 165272 temp_mapscr->warpreturny[3]=0;
15665
15666
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15667 {
15668
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15669 {
15670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
15671 {
15672 return qe_invalid;
15673 }
15674 401880 }
15675
15676
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(version>=18)
15677 {
15678
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
15679 {
15680 return qe_invalid;
15681 }
15682 133960 }
15683 else
15684 {
15685 byte temp;
15686
15687 if(!p_getc(&temp,f,true))
15688 {
15689 return qe_invalid;
15690 }
15691
15692 temp_mapscr->warpreturnc=temp<<8|temp;
15693 }
15694 133960 }
15695
15696
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->stairx),f,true))
15697
15698 {
15699 return qe_invalid;
15700 }
15701
15702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->stairy),f,true))
15703 {
15704 return qe_invalid;
15705 }
15706
15707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->itemx),f,true))
15708 {
15709 return qe_invalid;
15710 }
15711
15712
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->itemy),f,true))
15713 {
15714 return qe_invalid;
15715 }
15716
15717
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version > 15) // February 2009
15718 {
15719
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->color),f,true))
15720 {
15721 return qe_invalid;
15722 }
15723 133960 }
15724 else
15725 {
15726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31312 times.
31312 if(!p_getc(& tempbyte,f,true))
15727 {
15728 return qe_invalid;
15729 }
15730
15731 31312 temp_mapscr->color = (word) tempbyte;
15732 }
15733
15734
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
15735 {
15736 return qe_invalid;
15737 }
15738
15739
2/2
✓ Branch 0 taken 661088 times.
✓ Branch 1 taken 165272 times.
826360 for(int32_t k=0; k<4; k++)
15740 {
15741
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 661088 times.
661088 if(!p_getc(&(temp_mapscr->door[k]),f,true))
15742 {
15743 return qe_invalid;
15744
15745 }
15746 661088 }
15747
15748
2/2
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
165272 if(version <= 11)
15749 {
15750
1/2
✓ Branch 0 taken 31312 times.
✗ Branch 1 not taken.
31312 if(!p_getc(&(tempbyte),f,true))
15751 {
15752 return qe_invalid;
15753 }
15754
15755 31312 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15756
15757
2/6
✓ Branch 0 taken 31312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31312 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15758 {
15759 for(int32_t i=1; i<4; i++)
15760 {
15761 if(!p_getc(&(tempbyte),f,true))
15762 {
15763 return qe_invalid;
15764 }
15765
15766 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15767 }
15768 }
15769 else
15770 {
15771 31312 temp_mapscr->tilewarpdmap[1]=0;
15772 31312 temp_mapscr->tilewarpdmap[2]=0;
15773 31312 temp_mapscr->tilewarpdmap[3]=0;
15774 }
15775 31312 }
15776 else
15777 {
15778
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
15779 {
15780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
15781 {
15782 return qe_invalid;
15783 }
15784 535840 }
15785 }
15786
15787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f,true))
15788 {
15789 return qe_invalid;
15790 }
15791
15792
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15793 {
15794
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15795 {
15796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
15797 {
15798 return qe_invalid;
15799 }
15800 401880 }
15801 133960 }
15802 else
15803 {
15804 31312 temp_mapscr->tilewarpscr[1]=0;
15805 31312 temp_mapscr->tilewarpscr[2]=0;
15806 31312 temp_mapscr->tilewarpscr[3]=0;
15807 }
15808
15809
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version >= 15)
15810 {
15811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
15812 {
15813 return qe_invalid;
15814 }
15815 133960 }
15816 else
15817 {
15818 31312 temp_mapscr->tilewarpoverlayflags=0;
15819 }
15820
15821
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->exitdir),f,true))
15822 {
15823 return qe_invalid;
15824 }
15825
15826
2/2
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
165272 if(Header->zelda_version < 0x193)
15827 {
15828
1/2
✓ Branch 0 taken 3432 times.
✗ Branch 1 not taken.
3432 if(!p_getc(&tempbyte,f,true))
15829 {
15830 return qe_invalid;
15831 }
15832
15833 3432 }
15834
15835
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15836 {
15837 if(!p_getc(&padding,f,true))
15838 {
15839 return qe_invalid;
15840 }
15841 }
15842
15843
2/2
✓ Branch 0 taken 1652720 times.
✓ Branch 1 taken 165272 times.
1817992 for(int32_t k=0; k<10; k++)
15844 {
15845 /*
15846 if (!temp_mapscr->enemy[k])
15847 {
15848 continue;
15849 }
15850 */
15851
3/6
✓ Branch 0 taken 1618400 times.
✓ Branch 1 taken 34320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1652720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15852 {
15853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34320 times.
34320 if(!p_getc(&tempbyte,f,true))
15854 {
15855 return qe_invalid;
15856 }
15857
15858 34320 temp_mapscr->enemy[k]=tempbyte;
15859 34320 }
15860 else
15861 {
15862
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1618400 times.
1618400 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
15863 {
15864 return qe_invalid;
15865 }
15866 }
15867
15868
3/6
✓ Branch 0 taken 1618400 times.
✓ Branch 1 taken 34320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1618400 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1652720 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15869 {
15870 //using enumerations here is dangerous
15871 //very easy to break old quests -DD
15872
2/2
✓ Branch 0 taken 514 times.
✓ Branch 1 taken 33806 times.
34320 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15873 {
15874 514 temp_mapscr->enemy[k]+=5;
15875 514 }
15876
2/2
✓ Branch 0 taken 33778 times.
✓ Branch 1 taken 28 times.
33806 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15877 {
15878 28 temp_mapscr->enemy[k]+=1;
15879 28 }
15880 34320 }
15881
15882
2/2
✓ Branch 0 taken 1339600 times.
✓ Branch 1 taken 313120 times.
1652720 if(version < 9)
15883 {
15884
2/2
✓ Branch 0 taken 286447 times.
✓ Branch 1 taken 26673 times.
313120 if(temp_mapscr->enemy[k]>0)
15885 {
15886 26673 temp_mapscr->enemy[k]+=10;
15887 26673 }
15888 313120 }
15889 //don't read in any invalid data
15890
2/2
✓ Branch 0 taken 1652700 times.
✓ Branch 1 taken 20 times.
1652720 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15891 {
15892 20 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15893 20 temp_mapscr->enemy[k] = 0;
15894 20 }
15895 1652720 }
15896
15897
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->pattern),f,true))
15898 {
15899 return qe_invalid;
15900 }
15901
15902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f,true))
15903 {
15904 return qe_invalid;
15905 }
15906
15907
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15908 {
15909
2/2
✓ Branch 0 taken 401880 times.
✓ Branch 1 taken 133960 times.
535840 for(int32_t i=1; i<4; i++)
15910 {
15911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
15912 {
15913 return qe_invalid;
15914 }
15915 401880 }
15916 133960 }
15917 else
15918 {
15919 31312 temp_mapscr->sidewarptype[1]=0;
15920 31312 temp_mapscr->sidewarptype[2]=0;
15921 31312 temp_mapscr->sidewarptype[3]=0;
15922 }
15923
15924
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version >= 15)
15925 {
15926
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
15927 {
15928 return qe_invalid;
15929 }
15930 133960 }
15931 else
15932 {
15933 31312 temp_mapscr->sidewarpoverlayflags=0;
15934 }
15935
15936
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
15937 {
15938 return qe_invalid;
15939 }
15940
15941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
15942 {
15943 return qe_invalid;
15944 }
15945
15946
2/2
✓ Branch 0 taken 661088 times.
✓ Branch 1 taken 165272 times.
826360 for(int32_t k=0; k<4; k++)
15947 {
15948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 661088 times.
661088 if(!p_getc(&(temp_mapscr->path[k]),f,true))
15949 {
15950 return qe_invalid;
15951 }
15952 661088 }
15953
15954
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f,true))
15955 {
15956 return qe_invalid;
15957 }
15958
15959
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15960 {
15961
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 401880 times.
535840 for(int32_t i=1; i<4; i++)
15962 {
15963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 401880 times.
401880 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
15964 {
15965 return qe_invalid;
15966 }
15967 401880 }
15968 133960 }
15969 else
15970 {
15971 31312 temp_mapscr->sidewarpscr[1]=0;
15972 31312 temp_mapscr->sidewarpscr[2]=0;
15973 31312 temp_mapscr->sidewarpscr[3]=0;
15974 }
15975
15976
2/2
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
165272 if(version <= 11)
15977 {
15978
1/2
✓ Branch 0 taken 31312 times.
✗ Branch 1 not taken.
31312 if(!p_getc(&(tempbyte),f,true))
15979 {
15980 return qe_invalid;
15981 }
15982
15983 31312 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15984
15985
2/6
✓ Branch 0 taken 31312 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
31312 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15986 {
15987 for(int32_t i=1; i<4; i++)
15988 {
15989 if(!p_getc(&(tempbyte),f,true))
15990 {
15991 return qe_invalid;
15992 }
15993
15994 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15995 }
15996 }
15997 else
15998 {
15999 31312 temp_mapscr->sidewarpdmap[1]=0;
16000 31312 temp_mapscr->sidewarpdmap[2]=0;
16001 31312 temp_mapscr->sidewarpdmap[3]=0;
16002 }
16003 31312 }
16004 else
16005 {
16006
2/2
✓ Branch 0 taken 535840 times.
✓ Branch 1 taken 133960 times.
669800 for(int32_t i=0; i<4; i++)
16007 {
16008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 535840 times.
535840 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
16009 {
16010 return qe_invalid;
16011 }
16012 535840 }
16013 }
16014
16015
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16016 {
16017
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
16018 {
16019 return qe_invalid;
16020 }
16021 133960 }
16022 31312 else temp_mapscr->sidewarpindex = 0;
16023
16024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
16025 {
16026 return qe_invalid;
16027 }
16028
16029
2/2
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
165272 if(Header->zelda_version < 0x193)
16030 {
16031
1/2
✓ Branch 0 taken 3432 times.
✗ Branch 1 not taken.
3432 if(!p_getc(&(temp_mapscr->old_cpage),f,true))
16032 {
16033 return qe_invalid;
16034 }
16035 3432 }
16036
16037
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->undercset),f,true)) //recalculated for older quests
16038 {
16039 return qe_invalid;
16040 }
16041
16042
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16043 {
16044 return qe_invalid;
16045 }
16046
16047
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(!p_getc(&(temp_mapscr->flags),f,true))
16048 {
16049 return qe_invalid;
16050 }
16051
16052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->flags2),f,true))
16053 {
16054 return qe_invalid;
16055 }
16056
16057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
165272 if(!p_getc(&(temp_mapscr->flags3),f,true))
16058 {
16059 return qe_invalid;
16060 }
16061
16062
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16063 //if (version>2)
16064 {
16065
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags4),f,true))
16066 {
16067 return qe_invalid;
16068 }
16069 133960 }
16070
16071
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16072 {
16073
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags5),f,true))
16074 {
16075 return qe_invalid;
16076 }
16077
16078
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->noreset),f,true))
16079 {
16080 return qe_invalid;
16081 }
16082
16083
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
16084 {
16085 return qe_invalid;
16086 }
16087
16088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(temp_mapscr->flags5&32)
16089 {
16090 temp_mapscr->flags5 &= ~32;
16091 temp_mapscr->noreset |= 48;
16092 }
16093
16094
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(version<8)
16095 {
16096 if(temp_mapscr->noreset&1)
16097 {
16098 temp_mapscr->noreset|=8192;
16099 }
16100
16101 if(temp_mapscr->nocarry&1)
16102 {
16103 temp_mapscr->nocarry|=8192;
16104 temp_mapscr->nocarry&=~1;
16105 }
16106 }
16107 133960 }
16108 else
16109 {
16110 31312 temp_mapscr->flags5 = 0;
16111 31312 temp_mapscr->noreset = 0;
16112 31312 temp_mapscr->nocarry = 0;
16113 }
16114
16115
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16116 {
16117
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags6),f,true))
16118 {
16119 return qe_invalid;
16120 }
16121 133960 }
16122
16123
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version>5)
16124 {
16125
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags7),f,true))
16126 {
16127 return qe_invalid;
16128 }
16129
16130
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags8),f,true))
16131 {
16132 return qe_invalid;
16133 }
16134
16135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->flags9),f,true))
16136 {
16137 return qe_invalid;
16138 }
16139
16140
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->flags10),f,true))
16141 {
16142 return qe_invalid;
16143 }
16144
16145
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->csensitive),f,true))
16146 {
16147 return qe_invalid;
16148 }
16149 133960 }
16150 else
16151 {
16152 31312 temp_mapscr->csensitive=1;
16153 }
16154
16155
2/2
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
165272 if(version<14) // August 2007: screen SFX added
16156 {
16157
2/2
✓ Branch 0 taken 31248 times.
✓ Branch 1 taken 64 times.
31312 if(temp_mapscr->flags&8) //fROAR
16158 {
16159 64 temp_mapscr->bosssfx=
16160
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 55 times.
64 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16161 55 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16162 WAV_ROAR;
16163 64 }
16164
16165
2/2
✓ Branch 0 taken 87 times.
✓ Branch 1 taken 31225 times.
31312 if(temp_mapscr->flags&128) //fSEA
16166 {
16167 87 temp_mapscr->oceansfx=WAV_SEA;
16168 87 }
16169
16170 31312 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16171 ? 0 : WAV_SECRET;
16172
16173 31312 temp_mapscr->flags3 &= ~66; //64|2
16174 31312 temp_mapscr->flags2 &= ~32;
16175 31312 temp_mapscr->flags &= ~136; // 128|8
16176 31312 }
16177 else
16178 {
16179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
16180 {
16181 return qe_invalid;
16182 }
16183
16184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
16185 {
16186 return qe_invalid;
16187 }
16188
16189
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
16190 {
16191 return qe_invalid;
16192 }
16193 }
16194
16195
2/2
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
165272 if(version<15) // October 2007: another SFX
16196 {
16197 31312 temp_mapscr->holdupsfx=WAV_PICKUP;
16198 31312 }
16199 else
16200 {
16201
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
16202 {
16203 return qe_invalid;
16204 }
16205 }
16206
16207
16208
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16209 {
16210
2/2
✓ Branch 0 taken 971040 times.
✓ Branch 1 taken 161840 times.
1132880 for(int32_t k=0; k<6; k++)
16211 {
16212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 971040 times.
971040 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
16213 {
16214 return qe_invalid;
16215 }
16216 971040 }
16217
16218
2/2
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 971040 times.
1132880 for(int32_t k=0; k<6; k++)
16219 {
16220
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 971040 times.
971040 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
16221 {
16222 return qe_invalid;
16223 }
16224 971040 }
16225 161840 }
16226
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3432 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16227 {
16228 if(!p_getc(&(temp_mapscr->layermap[2]),f,true))
16229 {
16230 return qe_invalid;
16231 }
16232
16233 if(!p_getc(&(temp_mapscr->layerscreen[2]),f,true))
16234 {
16235 return qe_invalid;
16236 }
16237
16238 if(!p_getc(&(temp_mapscr->layermap[4]),f,true))
16239 {
16240 return qe_invalid;
16241 }
16242
16243 if(!p_getc(&(temp_mapscr->layerscreen[4]),f,true))
16244
16245 {
16246 return qe_invalid;
16247 }
16248 }
16249
16250
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
165272 if((Header->zelda_version == 0x192)&&(Header->build>149))
16251 {
16252 for(int32_t k=0; k<6; k++)
16253 {
16254 if(!p_getc(&tempbyte,f,true)) //layerxsize
16255 {
16256 return qe_invalid;
16257 }
16258 }
16259
16260 for(int32_t k=0; k<6; k++)
16261 {
16262 if(!p_getc(&tempbyte,f,true)) //layerxspeed
16263 {
16264 return qe_invalid;
16265 }
16266 }
16267
16268 for(int32_t k=0; k<6; k++)
16269 {
16270 if(!p_getc(&tempbyte,f,true)) //layerxdelay
16271 {
16272 return qe_invalid;
16273 }
16274 }
16275
16276 for(int32_t k=0; k<6; k++)
16277 {
16278 if(!p_getc(&tempbyte,f,true)) //layerysize
16279 {
16280 return qe_invalid;
16281 }
16282 }
16283
16284 for(int32_t k=0; k<6; k++)
16285 {
16286 if(!p_getc(&tempbyte,f,true)) //layeryspeed
16287 {
16288 return qe_invalid;
16289 }
16290 }
16291
16292 for(int32_t k=0; k<6; k++)
16293 {
16294 if(!p_getc(&tempbyte,f,true)) //layerydelay
16295 {
16296 return qe_invalid;
16297 }
16298 }
16299 }
16300
16301
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16302 {
16303
2/2
✓ Branch 0 taken 971040 times.
✓ Branch 1 taken 161840 times.
1132880 for(int32_t k=0; k<6; k++)
16304 {
16305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 971040 times.
971040 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
16306 {
16307 return qe_invalid;
16308 }
16309 971040 }
16310 161840 }
16311
16312
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16313 {
16314
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161840 if((Header->zelda_version == 0x192)&&(Header->build>153))
16315 {
16316 if(!p_getc(&padding,f,true))
16317 {
16318 return qe_invalid;
16319 }
16320 }
16321
16322
1/2
✓ Branch 0 taken 161840 times.
✗ Branch 1 not taken.
161840 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
16323 {
16324 return qe_invalid;
16325 }
16326 161840 }
16327
16328
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16329 {
16330 3432 extras=15;
16331 3432 }
16332
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161840 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16333 {
16334 extras=11;
16335 }
16336
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161840 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16337 {
16338 extras=32;
16339 }
16340
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161840 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16341 {
16342 extras=64;
16343 }
16344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
161840 else if(Header->zelda_version < 0x193)
16345 {
16346 extras=62;
16347 }
16348 else
16349
16350 {
16351 161840 extras=0;
16352 }
16353
16354
2/2
✓ Branch 0 taken 51480 times.
✓ Branch 1 taken 165272 times.
216752 for(int32_t k=0; k<extras; k++)
16355 {
16356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 51480 times.
51480 if(!p_getc(&tempbyte,f,true)) //extra[k]
16357 {
16358 return qe_invalid;
16359 }
16360 51480 }
16361
16362
3/6
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 31312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16363 //if (version>3)
16364 {
16365
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_getc(&(temp_mapscr->nextmap),f,true))
16366 {
16367 return qe_invalid;
16368 }
16369
16370
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->nextscr),f,true))
16371 {
16372 return qe_invalid;
16373 }
16374 133960 }
16375 else
16376 {
16377 31312 temp_mapscr->nextmap=0;
16378 31312 temp_mapscr->nextscr=0;
16379 }
16380
16381
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16382 {
16383 3432 secretcombos=20;
16384 3432 }
16385
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
161840 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16386 {
16387 secretcombos=256;
16388 }
16389 else
16390 {
16391 161840 secretcombos=128;
16392 }
16393
16394
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16395 {
16396
2/2
✓ Branch 0 taken 68640 times.
✓ Branch 1 taken 3432 times.
72072 for(int32_t k=0; k<secretcombos; k++)
16397 {
16398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f,true))
16399 {
16400 return qe_invalid;
16401 }
16402
16403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(k<128)
16404 {
16405 68640 temp_mapscr->secretcombo[k]=tempbyte;
16406 68640 }
16407 68640 }
16408 3432 }
16409 else
16410 {
16411
2/2
✓ Branch 0 taken 20715520 times.
✓ Branch 1 taken 161840 times.
20877360 for(int32_t k=0; k<128; k++)
16412 {
16413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20715520 times.
20715520 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
16414 {
16415 return qe_invalid;
16416 }
16417
16418 20715520 }
16419 }
16420
16421
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16422 {
16423
2/2
✓ Branch 0 taken 20715520 times.
✓ Branch 1 taken 161840 times.
20877360 for(int32_t k=0; k<128; k++)
16424 {
16425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20715520 times.
20715520 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
16426 {
16427 return qe_invalid;
16428 }
16429 20715520 }
16430
16431
2/2
✓ Branch 0 taken 20715520 times.
✓ Branch 1 taken 161840 times.
20877360 for(int32_t k=0; k<128; k++)
16432 {
16433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20715520 times.
20715520 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
16434 {
16435 return qe_invalid;
16436 }
16437 20715520 }
16438 161840 }
16439
16440
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16441 {
16442 if(!p_getc(&padding,f,true))
16443 {
16444 return qe_invalid;
16445 }
16446 }
16447
16448 165272 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16449
16450
2/2
✓ Branch 0 taken 29087872 times.
✓ Branch 1 taken 165272 times.
29253144 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16451 {
16452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29087872 times.
29087872 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
16453 {
16454 return qe_invalid;
16455 }
16456 29087872 }
16457
16458
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 165272 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16459 {
16460 if(!p_getc(&padding,f,true))
16461 {
16462 return qe_invalid;
16463 }
16464
16465 if(!p_getc(&padding,f,true))
16466 {
16467 return qe_invalid;
16468 }
16469 }
16470
16471
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16472 {
16473
2/2
✓ Branch 0 taken 28483840 times.
✓ Branch 1 taken 161840 times.
28645680 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16474 {
16475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28483840 times.
28483840 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
16476 {
16477 return qe_invalid;
16478 }
16479
16480
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 28483840 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
28483840 if((Header->zelda_version == 0x192)&&(Header->build<24))
16481 {
16482 if(!p_getc(&tempbyte,f,true))
16483 {
16484 return qe_invalid;
16485 }
16486
16487 if(!p_getc(&tempbyte,f,true))
16488 {
16489 return qe_invalid;
16490 }
16491
16492 if(!p_getc(&tempbyte,f,true))
16493 {
16494 return qe_invalid;
16495 }
16496 }
16497 28483840 }
16498 161840 }
16499
16500
3/6
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 161840 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3432 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16501 {
16502
2/2
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 28483840 times.
28645680 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16503 {
16504
16505
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28483840 times.
28483840 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
16506 {
16507 return qe_invalid;
16508 }
16509 28483840 }
16510 161840 }
16511
16512
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16513 {
16514 3432 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16515 3432 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16516 3432 }
16517
16518
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16519 {
16520 3432 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16521 3432 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16522 3432 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16523 3432 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16524 3432 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16525 3432 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16526 3432 }
16527
16528
3/6
✓ Branch 0 taken 161840 times.
✓ Branch 1 taken 3432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 161840 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
165272 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16529 {
16530
2/2
✓ Branch 0 taken 604032 times.
✓ Branch 1 taken 3432 times.
607464 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16531 {
16532
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604032 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604032 if((Header->zelda_version == 0x192)&&(Header->build>149))
16533 {
16534 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16535 {
16536 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16537 }
16538 }
16539 else
16540 {
16541
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 604032 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
604032 if((Header->zelda_version < 0x192)||
16542 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16543 {
16544 604032 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16545 604032 }
16546
16547 604032 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16548 }
16549
16550 604032 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16551 604032 }
16552 3432 }
16553
16554 /*if(version>12)
16555 {
16556 if(!p_getc(&(temp_mapscr->scrWidth),f,true))
16557 {
16558 return qe_invalid;
16559 }
16560 if(!p_getc(&(temp_mapscr->scrHeight),f,true))
16561 {
16562 return qe_invalid;
16563 }
16564 }*/
16565
16566
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version>4)
16567 {
16568
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
16569 {
16570 return qe_invalid;
16571 }
16572 133960 }
16573 else
16574 {
16575 31312 temp_mapscr->screen_midi = -1;
16576 }
16577
16578
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version>=17)
16579 {
16580
1/2
✓ Branch 0 taken 133960 times.
✗ Branch 1 not taken.
133960 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
16581 {
16582 return qe_invalid;
16583 }
16584 133960 }
16585 else
16586 {
16587 31312 temp_mapscr->lens_layer = llNORMAL;
16588 }
16589
16590
2/2
✓ Branch 0 taken 31312 times.
✓ Branch 1 taken 133960 times.
165272 if(version>6)
16591 {
16592 dword bits;
16593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 133960 times.
133960 if(!p_igetl(&bits,f,true))
16594 {
16595 return qe_invalid;
16596 }
16597
16598 int32_t m;
16599 float tempfloat;
16600 word tempw;
16601 133960 temp_mapscr->ffcCountMarkDirty();
16602
16603
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 4286720 times.
4420680 for(m=0; m<32; m++)
16604 {
16605 4286720 ffcdata& tempffc = temp_mapscr->ffcs[m];
16606 4286720 tempffc.clear();
16607
2/2
✓ Branch 0 taken 4275651 times.
✓ Branch 1 taken 11069 times.
4286720 if((bits>>m)&1)
16608 {
16609
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetw(&tempw,f,true))
16610 {
16611 return qe_invalid;
16612 }
16613 11069 tempffc.setData(tempw);
16614
16615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.cset),f,true))
16616 {
16617 return qe_invalid;
16618 }
16619
16620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.delay),f,true))
16621 {
16622 return qe_invalid;
16623 }
16624
16625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(version < 9)
16626 {
16627 if(!p_igetf(&tempfloat,f,true))
16628 {
16629 return qe_invalid;
16630 }
16631
16632 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16633
16634 if(!p_igetf(&tempfloat,f,true))
16635 {
16636 return qe_invalid;
16637 }
16638
16639 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16640
16641 if(!p_igetf(&tempfloat,f,true))
16642 {
16643 return qe_invalid;
16644 }
16645
16646 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16647
16648 if(!p_igetf(&tempfloat,f,true))
16649 {
16650 return qe_invalid;
16651 }
16652
16653 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16654
16655 if(!p_igetf(&tempfloat,f,true))
16656 {
16657 return qe_invalid;
16658 }
16659
16660 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16661
16662 if(!p_igetf(&tempfloat,f,true))
16663 {
16664 return qe_invalid;
16665 }
16666
16667 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16668 }
16669 else
16670 {
16671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.x),f,true))
16672 {
16673 return qe_invalid;
16674 }
16675
16676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.y),f,true))
16677 {
16678 return qe_invalid;
16679 }
16680
16681
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(!p_igetzf(&(tempffc.vx),f,true))
16682 {
16683 return qe_invalid;
16684 }
16685
16686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.vy),f,true))
16687 {
16688 return qe_invalid;
16689 }
16690
16691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ax),f,true))
16692 {
16693 return qe_invalid;
16694 }
16695
16696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetzf(&(tempffc.ay),f,true))
16697 {
16698 return qe_invalid;
16699 }
16700 }
16701
16702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempffc.link),f,true))
16703 {
16704 return qe_invalid;
16705 }
16706
16707
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>7)
16708 {
16709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16710 {
16711 return qe_invalid;
16712 }
16713
16714 11069 tempffc.hxsz = (tempbyte&0x3F)+1;
16715 11069 tempffc.txsz = (tempbyte>>6)+1;
16716
16717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&tempbyte,f,true))
16718 {
16719 return qe_invalid;
16720 }
16721
16722 11069 tempffc.hysz = (tempbyte&0x3F)+1;
16723 11069 tempffc.tysz = (tempbyte>>6)+1;
16724
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.flags),f,true))
16726 {
16727 return qe_invalid;
16728 }
16729 11069 }
16730 else
16731 {
16732 tempffc.hxsz=16;
16733 tempffc.hysz=16;
16734 tempffc.txsz=1;
16735 tempffc.tysz=1;
16736 tempffc.flags=0;
16737 }
16738
16739 11069 tempffc.updateSolid();
16740
16741
16742
4/6
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9049 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9049 times.
11069 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16743 {
16744 tempffc.flags|=ffIGNOREHOLDUP;
16745 }
16746
16747
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>9)
16748 {
16749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetw(&(tempffc.script),f,true))
16750 {
16751 return qe_invalid;
16752 }
16753 11069 }
16754 else
16755 {
16756 tempffc.script=0;
16757 }
16758
16759
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version>10)
16760 {
16761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[0]),f,true))
16762 {
16763 return qe_invalid;
16764 }
16765
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[1]),f,true))
16767 {
16768 return qe_invalid;
16769 }
16770
16771
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[2]),f,true))
16772 {
16773 return qe_invalid;
16774 }
16775
16776
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[3]),f,true))
16777 {
16778 return qe_invalid;
16779 }
16780
16781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[4]),f,true))
16782 {
16783 return qe_invalid;
16784 }
16785
16786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[5]),f,true))
16787 {
16788 return qe_invalid;
16789 }
16790
16791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[6]),f,true))
16792 {
16793 return qe_invalid;
16794 }
16795
16796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_igetl(&(tempffc.initd[7]),f,true))
16797 {
16798 return qe_invalid;
16799 }
16800
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16802 {
16803 return qe_invalid;
16804 }
16805
16806 11069 tempffc.inita[0]=tempbyte*10000;
16807
16808
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11069 times.
11069 if(!p_getc(&(tempbyte),f,true))
16809 {
16810 return qe_invalid;
16811 }
16812
16813 11069 tempffc.inita[1]=tempbyte*10000;
16814 11069 }
16815 else
16816 {
16817 tempffc.inita[0] = 10000;
16818 tempffc.inita[1] = 10000;
16819 }
16820
16821 11069 tempffc.initialized = false;
16822
16823
1/2
✓ Branch 0 taken 11069 times.
✗ Branch 1 not taken.
11069 if(version <= 11)
16824 {
16825 fixffcs=true;
16826 }
16827 11069 }
16828 4286720 }
16829
16830 133960 }
16831
16832 //add in the new whistle flags
16833
2/2
✓ Branch 0 taken 133960 times.
✓ Branch 1 taken 31312 times.
165272 if(version<13)
16834 {
16835
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 31300 times.
31312 if(temp_mapscr->flags & fWHISTLE)
16836 {
16837 12 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16838 12 }
16839 31312 }
16840
16841 // for(int32_t m=0; m<32; m++)
16842 // {
16843 // // ffcScriptData used to be part of mapscr, and this was handled just above
16844 // ffcScriptData[m].a[0] = 10000;
16845 // ffcScriptData[m].a[1] = 10000;
16846 // }
16847
16848 //2.55 starts here
16849
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 151536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
165272 if ( version >= 19 && Header->zelda_version > 0x253 )
16850 {
16851
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16852 {
16853
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
16854 {
16855 return qe_invalid;
16856 }
16857 137360 }
16858
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16859 {
16860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
16861 {
16862 return qe_invalid;
16863 }
16864 137360 }
16865
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16866 {
16867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
16868 {
16869 return qe_invalid;
16870 }
16871 137360 }
16872
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16873 {
16874
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
16875 {
16876 return qe_invalid;
16877 }
16878 137360 }
16879 13736 }
16880
3/4
✓ Branch 0 taken 151536 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 151536 times.
165272 if ( version < 19 && Header->zelda_version > 0x253 )
16881 {
16882 for ( int32_t q = 0; q < 10; q++ )
16883 {
16884 temp_mapscr->npcstrings[q] = 0;
16885 temp_mapscr->new_items[q] = 0;
16886 temp_mapscr->new_item_x[q] = 0;
16887 temp_mapscr->new_item_y[q] = 0;
16888 }
16889 }
16890
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 151536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
165272 if ( version >= 20 && Header->zelda_version > 0x253 )
16891 {
16892
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f,true))
16893 {
16894 return qe_invalid;
16895 }
16896
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16897 {
16898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
16899 {
16900 return qe_invalid;
16901 }
16902 109888 }
16903 13736 }
16904
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 151536 times.
165272 if ( version < 20 )
16905 {
16906 151536 temp_mapscr->script = 0;
16907
2/2
✓ Branch 0 taken 1212288 times.
✓ Branch 1 taken 151536 times.
1363824 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16908 151536 }
16909
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 151536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
165272 if ( version >= 21 && Header->zelda_version > 0x253 )
16910 {
16911
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
16912 {
16913 return qe_invalid;
16914 }
16915 13736 }
16916
2/2
✓ Branch 0 taken 151536 times.
✓ Branch 1 taken 13736 times.
165272 if ( version < 21 )
16917 {
16918 151536 temp_mapscr->preloadscript = 0;
16919 151536 }
16920 //all builds with version > 20 need this. -Z
16921 165272 temp_mapscr->ffcswaitdraw = 0;
16922
16923
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 151536 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
165272 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16924 {
16925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f,true))
16926 {
16927 return qe_invalid;
16928 }
16929
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f,true))
16930 {
16931 return qe_invalid;
16932 }
16933 13736 }
16934
2/2
✓ Branch 0 taken 151536 times.
✓ Branch 1 taken 13736 times.
165272 if ( version < 22 )
16935 {
16936 151536 temp_mapscr->hidelayers = 0;
16937 151536 temp_mapscr->hidescriptlayers = 0;
16938 151536 }
16939
16940 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16941 //May be any version before 2.11. -Z
16942 /* --not the roar, the HIT SFX
16943 if ( Header->zelda_version <= 0x210 )
16944 {
16945 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16946 {
16947 temp_mapscr->bosssfx = WAV_ROAR;
16948 }
16949 }
16950 */
16951
16952 165272 return 0;
16953 165272 }
16954 177784 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
16955 {
16956
2/2
✓ Branch 0 taken 165272 times.
✓ Branch 1 taken 12512 times.
177784 if(version < 23)
16957 {
16958 165272 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16959
1/2
✓ Branch 0 taken 165272 times.
✗ Branch 1 not taken.
165272 if(ret) return ret;
16960 165272 }
16961 else
16962 {
16963
1/2
✓ Branch 0 taken 12512 times.
✗ Branch 1 not taken.
12512 if(!p_getc(&(temp_mapscr->valid),f,true))
16964 return qe_invalid;
16965
2/2
✓ Branch 0 taken 5245 times.
✓ Branch 1 taken 7267 times.
12512 if(!(temp_mapscr->valid & mVALID))
16966 7267 return 0; //Empty screen
16967 uint32_t scr_has_flags;
16968
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5245 times.
5245 if(!p_igetl(&scr_has_flags,f,true))
16969 return qe_invalid;
16970
16971
2/2
✓ Branch 0 taken 5200 times.
✓ Branch 1 taken 45 times.
5245 if(scr_has_flags & SCRHAS_ROOMDATA)
16972 {
16973
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_getc(&(temp_mapscr->guy),f,true))
16974 return qe_invalid;
16975
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->str),f,true))
16976 return qe_invalid;
16977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45 times.
45 if(!p_getc(&(temp_mapscr->room),f,true))
16978 return qe_invalid;
16979
1/2
✓ Branch 0 taken 45 times.
✗ Branch 1 not taken.
45 if(!p_igetw(&(temp_mapscr->catchall),f,true))
16980 return qe_invalid;
16981 45 }
16982
2/2
✓ Branch 0 taken 5164 times.
✓ Branch 1 taken 81 times.
5245 if(scr_has_flags & SCRHAS_ITEM)
16983 {
16984
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->item),f,true))
16985 return qe_invalid;
16986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 81 times.
81 if(!p_getc(&(temp_mapscr->hasitem),f,true))
16987 return qe_invalid;
16988
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemx),f,true))
16989 return qe_invalid;
16990
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_getc(&(temp_mapscr->itemy),f,true))
16991 return qe_invalid;
16992 81 }
16993
2/2
✓ Branch 0 taken 4953 times.
✓ Branch 1 taken 292 times.
5245 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16994 {
16995
1/2
✓ Branch 0 taken 292 times.
✗ Branch 1 not taken.
292 if(!p_igetw(&temp_mapscr->warpreturnc,f,true))
16996 return qe_invalid;
16997 292 }
16998
2/2
✓ Branch 0 taken 5047 times.
✓ Branch 1 taken 198 times.
5245 if(scr_has_flags & SCRHAS_TWARP)
16999 {
17000
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17001 {
17002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f,true))
17003 return qe_invalid;
17004 792 }
17005
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17006 {
17007
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f,true))
17008 return qe_invalid;
17009 792 }
17010
2/2
✓ Branch 0 taken 792 times.
✓ Branch 1 taken 198 times.
990 for(int32_t i=0; i<4; i++)
17011 {
17012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 792 times.
792 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f,true))
17013 return qe_invalid;
17014 792 }
17015
1/2
✓ Branch 0 taken 198 times.
✗ Branch 1 not taken.
198 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f,true))
17016 return qe_invalid;
17017 198 }
17018
2/2
✓ Branch 0 taken 5127 times.
✓ Branch 1 taken 118 times.
5245 if(scr_has_flags & SCRHAS_SWARP)
17019 {
17020
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17021 {
17022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f,true))
17023 return qe_invalid;
17024 472 }
17025
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17026 {
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f,true))
17028 return qe_invalid;
17029 472 }
17030
2/2
✓ Branch 0 taken 472 times.
✓ Branch 1 taken 118 times.
590 for(int32_t i=0; i<4; i++)
17031 {
17032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 472 times.
472 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f,true))
17033 return qe_invalid;
17034 472 }
17035
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f,true))
17036 return qe_invalid;
17037
1/2
✓ Branch 0 taken 118 times.
✗ Branch 1 not taken.
118 if(!p_getc(&(temp_mapscr->sidewarpindex),f,true))
17038 return qe_invalid;
17039 118 }
17040
2/2
✓ Branch 0 taken 4949 times.
✓ Branch 1 taken 296 times.
5245 if(scr_has_flags & SCRHAS_WARPRET)
17041 {
17042
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17043 {
17044
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f,true))
17045 return qe_invalid;
17046 1184 }
17047
2/2
✓ Branch 0 taken 1184 times.
✓ Branch 1 taken 296 times.
1480 for(int32_t i=0; i<4; i++)
17048 {
17049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1184 times.
1184 if(!p_getc(&(temp_mapscr->warpreturny[i]),f,true))
17050 return qe_invalid;
17051 1184 }
17052
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivalx),f,true))
17053 return qe_invalid;
17054
1/2
✓ Branch 0 taken 296 times.
✗ Branch 1 not taken.
296 if(!p_getc(&(temp_mapscr->warparrivaly),f,true))
17055 return qe_invalid;
17056 296 }
17057
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 4213 times.
5245 if(scr_has_flags & SCRHAS_LAYERS)
17058 {
17059
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17060 {
17061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layermap[k]),f,true))
17062 return qe_invalid;
17063 6192 }
17064
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17065 {
17066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layerscreen[k]),f,true))
17067 return qe_invalid;
17068 6192 }
17069
2/2
✓ Branch 0 taken 6192 times.
✓ Branch 1 taken 1032 times.
7224 for(int32_t k=0; k<6; k++)
17070 {
17071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6192 times.
6192 if(!p_getc(&(temp_mapscr->layeropacity[k]),f,true))
17072 return qe_invalid;
17073 6192 }
17074
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(!p_getc(&(temp_mapscr->hidelayers),f,true))
17075 return qe_invalid;
17076
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(!p_getc(&(temp_mapscr->hidescriptlayers),f,true))
17077 return qe_invalid;
17078 1032 }
17079 else
17080 {
17081
2/2
✓ Branch 0 taken 25278 times.
✓ Branch 1 taken 4213 times.
29491 for(int32_t k=0; k<6; k++)
17082 {
17083 25278 temp_mapscr->layeropacity[k] = 255;
17084 25278 }
17085 }
17086
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(scr_has_flags & SCRHAS_MAZE)
17087 {
17088 for(int32_t k=0; k<4; k++)
17089 {
17090 if(!p_getc(&(temp_mapscr->path[k]),f,true))
17091 return qe_invalid;
17092 }
17093 if(!p_getc(&(temp_mapscr->exitdir),f,true))
17094 return qe_invalid;
17095 }
17096
2/2
✓ Branch 0 taken 5145 times.
✓ Branch 1 taken 100 times.
5245 if(scr_has_flags & SCRHAS_D_S_U)
17097 {
17098
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_igetw(&(temp_mapscr->door_combo_set),f,true))
17099 return qe_invalid;
17100
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 100 times.
500 for(int32_t k=0; k<4; k++)
17101 {
17102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 400 times.
400 if(!p_getc(&(temp_mapscr->door[k]),f,true))
17103 return qe_invalid;
17104 400 }
17105
17106
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->stairx),f,true))
17107 return qe_invalid;
17108
17109
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->stairy),f,true))
17110 return qe_invalid;
17111
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100 times.
100 if(!p_igetw(&(temp_mapscr->undercombo),f,true))
17112 return qe_invalid;
17113
1/2
✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
100 if(!p_getc(&(temp_mapscr->undercset),f,true))
17114 return qe_invalid;
17115 100 }
17116
2/2
✓ Branch 0 taken 4886 times.
✓ Branch 1 taken 359 times.
5245 if(scr_has_flags & SCRHAS_FLAGS)
17117 {
17118
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags),f,true))
17119 return qe_invalid;
17120
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags2),f,true))
17121 return qe_invalid;
17122
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags3),f,true))
17123 return qe_invalid;
17124
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags4),f,true))
17125 return qe_invalid;
17126
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags5),f,true))
17127 return qe_invalid;
17128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
359 if(!p_getc(&(temp_mapscr->flags6),f,true))
17129 return qe_invalid;
17130
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags7),f,true))
17131 return qe_invalid;
17132
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags8),f,true))
17133 return qe_invalid;
17134
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags9),f,true))
17135 return qe_invalid;
17136
1/2
✓ Branch 0 taken 359 times.
✗ Branch 1 not taken.
359 if(!p_getc(&(temp_mapscr->flags10),f,true))
17137 return qe_invalid;
17138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
359 if(!p_getc(&(temp_mapscr->enemyflags),f,true))
17139 return qe_invalid;
17140 359 }
17141
2/2
✓ Branch 0 taken 4927 times.
✓ Branch 1 taken 318 times.
5245 if(scr_has_flags & SCRHAS_ENEMY)
17142 {
17143
2/2
✓ Branch 0 taken 3180 times.
✓ Branch 1 taken 318 times.
3498 for(int32_t k=0; k<10; k++)
17144 {
17145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3180 times.
3180 if(!p_igetw(&(temp_mapscr->enemy[k]),f,true))
17146 return qe_invalid;
17147
1/2
✓ Branch 0 taken 3180 times.
✗ Branch 1 not taken.
3180 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17148 temp_mapscr->enemy[k] = 0;
17149 3180 }
17150
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->pattern),f,true))
17151 return qe_invalid;
17152 318 }
17153
2/2
✓ Branch 0 taken 5214 times.
✓ Branch 1 taken 31 times.
5245 if(scr_has_flags & SCRHAS_CARRY)
17154 {
17155
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->noreset),f,true))
17156 return qe_invalid;
17157
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&(temp_mapscr->nocarry),f,true))
17158 return qe_invalid;
17159
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextmap),f,true))
17160 return qe_invalid;
17161
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_getc(&(temp_mapscr->nextscr),f,true))
17162 return qe_invalid;
17163 31 }
17164
2/2
✓ Branch 0 taken 5221 times.
✓ Branch 1 taken 24 times.
5245 if(scr_has_flags & SCRHAS_SCRIPT)
17165 {
17166
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&(temp_mapscr->script),f,true))
17167 return qe_invalid;
17168
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&(temp_mapscr->preloadscript),f,true))
17169 return qe_invalid;
17170
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 24 times.
216 for ( int32_t q = 0; q < 8; q++ )
17171 {
17172
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f,true))
17173 return qe_invalid;
17174 192 }
17175 24 }
17176
1/2
✓ Branch 0 taken 5245 times.
✗ Branch 1 not taken.
5245 if(scr_has_flags & SCRHAS_UNUSED)
17177 {
17178 for ( int32_t q = 0; q < 10; q++ )
17179 {
17180 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f,true))
17181 return qe_invalid;
17182 }
17183 for ( int32_t q = 0; q < 10; q++ )
17184 {
17185 if(!p_igetw(&(temp_mapscr->new_items[q]),f,true))
17186 return qe_invalid;
17187 }
17188 for ( int32_t q = 0; q < 10; q++ )
17189 {
17190 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f,true))
17191 return qe_invalid;
17192 }
17193 for ( int32_t q = 0; q < 10; q++ )
17194 {
17195 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f,true))
17196 return qe_invalid;
17197 }
17198 }
17199
2/2
✓ Branch 0 taken 4896 times.
✓ Branch 1 taken 349 times.
5245 if(scr_has_flags & SCRHAS_SECRETS)
17200 {
17201
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17202 {
17203
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f,true))
17204 return qe_invalid;
17205 44672 }
17206
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17207 {
17208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_getc(&(temp_mapscr->secretcset[k]),f,true))
17209 return qe_invalid;
17210 44672 }
17211
2/2
✓ Branch 0 taken 44672 times.
✓ Branch 1 taken 349 times.
45021 for(int32_t k=0; k<128; k++)
17212 {
17213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44672 times.
44672 if(!p_getc(&(temp_mapscr->secretflag[k]),f,true))
17214 return qe_invalid;
17215 44672 }
17216 349 }
17217
2/2
✓ Branch 0 taken 2859 times.
✓ Branch 1 taken 2386 times.
5245 if(scr_has_flags & SCRHAS_COMBOFLAG)
17218 {
17219
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17220 {
17221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_igetw(&(temp_mapscr->data[k]),f,true))
17222 return qe_invalid;
17223 419936 }
17224
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17225 {
17226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_getc(&(temp_mapscr->sflag[k]),f,true))
17227 return qe_invalid;
17228 419936 }
17229
2/2
✓ Branch 0 taken 419936 times.
✓ Branch 1 taken 2386 times.
422322 for(int32_t k=0; k<176; ++k)
17230 {
17231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 419936 times.
419936 if(!p_getc(&(temp_mapscr->cset[k]),f,true))
17232 return qe_invalid;
17233 419936 }
17234 2386 }
17235
2/2
✓ Branch 0 taken 5243 times.
✓ Branch 1 taken 2 times.
5245 if(scr_has_flags & SCRHAS_MISC)
17236 {
17237
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_igetw(&(temp_mapscr->color),f,true))
17238 return qe_invalid;
17239
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_getc(&(temp_mapscr->csensitive),f,true))
17240 return qe_invalid;
17241
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_getc(&(temp_mapscr->oceansfx),f,true))
17242 return qe_invalid;
17243
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_getc(&(temp_mapscr->bosssfx),f,true))
17244 return qe_invalid;
17245
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_getc(&(temp_mapscr->secretsfx),f,true))
17246 return qe_invalid;
17247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5243 times.
5243 if(!p_getc(&(temp_mapscr->holdupsfx),f,true))
17248 return qe_invalid;
17249
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_igetw(&(temp_mapscr->timedwarptics),f,true))
17250 return qe_invalid;
17251
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_igetw(&(temp_mapscr->screen_midi),f,true))
17252 return qe_invalid;
17253
1/2
✓ Branch 0 taken 5243 times.
✗ Branch 1 not taken.
5243 if(!p_getc(&(temp_mapscr->lens_layer),f,true))
17254 return qe_invalid;
17255 5243 }
17256 else
17257 {
17258 2 temp_mapscr->screen_midi = -1;
17259 2 temp_mapscr->csensitive = 1;
17260 }
17261 //FFC
17262 5245 bool old_ff = version < 25;
17263 5245 dword bits = 0;
17264 5245 word numffc = 32;
17265
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 5157 times.
5245 if(old_ff)
17266 {
17267
1/2
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
88 if(!p_igetl(&bits,f,true))
17268 return qe_invalid;
17269 88 }
17270 else
17271 {
17272
1/2
✓ Branch 0 taken 5157 times.
✗ Branch 1 not taken.
5157 if(!p_igetw(&numffc,f,true))
17273 return qe_invalid;
17274 }
17275 byte tempbyte;
17276 word tempw;
17277
4/6
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 5225 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20 times.
5245 static ffcdata nil_ffc;
17278 5245 temp_mapscr->ffcCountMarkDirty();
17279
2/2
✓ Branch 0 taken 5245 times.
✓ Branch 1 taken 8897 times.
14142 for(word m = 0; m < numffc; ++m)
17280 {
17281
1/2
✓ Branch 0 taken 8897 times.
✗ Branch 1 not taken.
8897 ffcdata& tempffc = (m < MAXFFCS)
17282 8897 ? temp_mapscr->ffcs[m]
17283 : nil_ffc; //sanity
17284 8897 tempffc.clear();
17285
3/4
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 6081 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2816 times.
8897 if(old_ff && !(bits & (1<<m))) continue;
17286
17287
1/2
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
6081 if(!p_igetw(&tempw,f,true))
17288 return qe_invalid;
17289
3/4
✓ Branch 0 taken 6081 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 965 times.
✓ Branch 3 taken 5116 times.
6081 if(!old_ff && !tempw) //empty ffc, nothing more to load
17290 5116 continue;
17291 965 tempffc.setData(tempw);
17292
17293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.cset),f,true))
17294 return qe_invalid;
17295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.delay),f,true))
17296 return qe_invalid;
17297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.x),f,true))
17298 return qe_invalid;
17299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.y),f,true))
17300 return qe_invalid;
17301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vx),f,true))
17302 return qe_invalid;
17303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetzf(&(tempffc.vy),f,true))
17304 return qe_invalid;
17305
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ax),f,true))
17306 return qe_invalid;
17307
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetzf(&(tempffc.ay),f,true))
17308 return qe_invalid;
17309
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.link),f,true))
17310 return qe_invalid;
17311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(version < 24)
17312 {
17313 if(!p_getc(&tempbyte,f,true))
17314 return qe_invalid;
17315 tempffc.hxsz = (tempbyte&0x3F)+1;
17316 tempffc.txsz = (tempbyte>>6)+1;
17317 if(!p_getc(&tempbyte,f,true))
17318 return qe_invalid;
17319 tempffc.hysz = (tempbyte&0x3F)+1;
17320 tempffc.tysz = (tempbyte>>6)+1;
17321 }
17322 else
17323 {
17324
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hxsz),f,true))
17325 return qe_invalid;
17326
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_igetl(&(tempffc.hysz),f,true))
17327 return qe_invalid;
17328
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempffc.txsz),f,true))
17329 return qe_invalid;
17330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempffc.tysz),f,true))
17331 return qe_invalid;
17332 }
17333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetl(&(tempffc.flags),f,true))
17334 return qe_invalid;
17335 965 tempffc.updateSolid();
17336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_igetw(&(tempffc.script),f,true))
17337 return qe_invalid;
17338
2/2
✓ Branch 0 taken 7720 times.
✓ Branch 1 taken 965 times.
8685 for(auto q = 0; q < 8; ++q)
17339 {
17340
1/2
✓ Branch 0 taken 7720 times.
✗ Branch 1 not taken.
7720 if(!p_igetl(&(tempffc.initd[q]),f,true))
17341 return qe_invalid;
17342 7720 }
17343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 965 times.
965 if(!p_getc(&(tempbyte),f,true))
17344 return qe_invalid;
17345 965 tempffc.inita[0]=tempbyte*10000;
17346
17347
1/2
✓ Branch 0 taken 965 times.
✗ Branch 1 not taken.
965 if(!p_getc(&(tempbyte),f,true))
17348 return qe_invalid;
17349 965 tempffc.inita[1]=tempbyte*10000;
17350
17351 965 tempffc.initialized = false;
17352 965 }
17353
2/2
✓ Branch 0 taken 662463 times.
✓ Branch 1 taken 5245 times.
667708 for(word m = numffc; m < MAXFFCS; ++m)
17354 {
17355 662463 temp_mapscr->ffcs[m].clear();
17356 662463 }
17357 //END FFC
17358 }
17359 170517 return 0;
17360 177784 }
17361
17362
17363 104 int32_t readmaps(PACKFILE *f, zquestheader *Header, bool keepdata)
17364 {
17365 104 int32_t scr=0;
17366
17367 104 word version=0;
17368 dword dummy;
17369 int32_t screens_to_read;
17370
17371 104 mapscr temp_mapscr;
17372 zcmap temp_map;
17373 word temp_map_count;
17374 dword section_size;
17375
17376
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17377 {
17378 2 screens_to_read=MAPSCRS192b136;
17379 2 }
17380 else
17381 {
17382 102 screens_to_read=MAPSCRS;
17383 }
17384
17385
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(Header->zelda_version > 0x192)
17386 {
17387 //section version info
17388
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&version,f,true))
17389 {
17390 return qe_invalid;
17391 }
17392
17393 102 FFCore.quest_format[vMaps] = version;
17394
17395 //al_trace("Maps version %d\n", version);
17396
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy,f,true))
17397 {
17398 return qe_invalid;
17399 }
17400
17401 //section size
17402
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&section_size,f,true))
17403 {
17404 return qe_invalid;
17405 }
17406
17407 //finally... section data
17408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(!p_igetw(&temp_map_count,f,true))
17409 {
17410 return 5;
17411 }
17412 102 }
17413 else
17414 {
17415 2 temp_map_count=map_count;
17416 }
17417
17418
17419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
17420 {
17421 104 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17422 104 TheMaps.resize(_mapsSize);
17423
17424
2/2
✓ Branch 0 taken 178840 times.
✓ Branch 1 taken 104 times.
178944 for(int32_t i(0); i<_mapsSize; i++)
17425 178840 TheMaps[i].zero_memory();
17426
17427 // Used to be done for each screen
17428
2/2
✓ Branch 0 taken 13312 times.
✓ Branch 1 taken 104 times.
13416 for(int32_t i=0; i<MAXFFCS; i++)
17429 {
17430 13312 ffcScriptData[i].a[0] = 10000;
17431 13312 ffcScriptData[i].a[1] = 10000;
17432 13312 }
17433
17434 104 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17435 104 }
17436
17437 104 temp_mapscr.zero_memory();
17438
17439 104 memset(&temp_map, 0, sizeof(zcmap));
17440 104 temp_map.scrResWidth = 256;
17441 104 temp_map.scrResHeight = 224;
17442 104 temp_map.tileWidth = 16;
17443 104 temp_map.tileHeight = 11;
17444 104 temp_map.viewWidth = 256;
17445 104 temp_map.viewHeight = 176;
17446 104 temp_map.viewX = 0;
17447 104 temp_map.viewY = 64;
17448 104 temp_map.subaWidth = 256;
17449 104 temp_map.subaHeight = 168;
17450 104 temp_map.subaTrans = false;
17451 104 temp_map.subpWidth = 256;
17452 104 temp_map.subpHeight = 56;
17453 104 temp_map.subpTrans = false;
17454
4/4
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1315 times.
✓ Branch 2 taken 1315 times.
✓ Branch 3 taken 104 times.
1419 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17455 {
17456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1315 times.
1315 if(keepdata==true) //!TODO Trim fully
17457 {
17458 1315 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17459 1315 }
17460 1315 byte valid=1;
17461
2/2
✓ Branch 0 taken 1216 times.
✓ Branch 1 taken 99 times.
1315 if(version > 22)
17462 {
17463
1/2
✓ Branch 0 taken 99 times.
✗ Branch 1 not taken.
99 if(!p_getc(&valid,f,true))
17464 return qe_invalid;
17465 99 }
17466
2/2
✓ Branch 0 taken 178736 times.
✓ Branch 1 taken 1315 times.
180051 for(int32_t j=0; j<screens_to_read; j++)
17467 {
17468 178736 scr=i*MAPSCRS+j;
17469 178736 clear_screen(&temp_mapscr);
17470
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 177784 times.
178736 if(valid)
17471 177784 readmapscreen(f, Header, &temp_mapscr, &temp_map, version);
17472
17473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 178736 times.
178736 if(keepdata==true)
17474 {
17475 178736 TheMaps[scr] = temp_mapscr;
17476 178736 }
17477 178736 }
17478
17479
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1315 times.
1315 if(keepdata==true)
17480 {
17481
3/6
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1289 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1315 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17482 {
17483 26 int32_t index = (i*MAPSCRS+132);
17484
17485 26 TheMaps[index]=TheMaps[index-1];
17486
17487 26 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17488 26 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17489 26 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17490
17491
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 26 times.
104 for(int32_t j=133; j<MAPSCRS; j++)
17492 {
17493 78 scr=i*MAPSCRS+j;
17494
17495 78 TheMaps[scr].zero_memory();
17496 78 TheMaps[scr].valid = mVERSION;
17497 78 TheMaps[scr].screen_midi = -1;
17498 78 TheMaps[scr].csensitive = 1;
17499 78 }
17500 26 }
17501
17502
3/6
✓ Branch 0 taken 1289 times.
✓ Branch 1 taken 26 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1289 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1315 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17503 {
17504
2/2
✓ Branch 0 taken 3536 times.
✓ Branch 1 taken 26 times.
3562 for(int32_t j=0; j<MAPSCRS; j++)
17505 {
17506 3536 scr=i*MAPSCRS+j;
17507 3536 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17508
17509
2/2
✓ Branch 0 taken 452608 times.
✓ Branch 1 taken 3536 times.
456144 for(int32_t k=0; k<128; k++)
17510 {
17511 452608 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17512 452608 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17513 452608 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17514 452608 }
17515 3536 }
17516 26 }
17517 1315 }
17518 1315 }
17519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata)
17520 {
17521 104 map_count = temp_map_count;
17522 104 }
17523 104 clear_screen(&temp_mapscr);
17524 104 return 0;
17525 104 }
17526
17527
17528 83 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos, bool keepdata)
17529 {
17530 83 reset_combo_animations();
17531 83 reset_combo_animations2();
17532
17533 83 init_combo_classes();
17534
17535 // combos
17536 83 word combos_used=0;
17537 int32_t dummy;
17538 byte padding;
17539 83 newcombo temp_combo;
17540 //word section_cversion=0;
17541
17542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(keepdata==true)
17543 {
17544
2/2
✓ Branch 0 taken 5418240 times.
✓ Branch 1 taken 83 times.
5418323 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17545 5418240 combobuf[q].clear();
17546 83 }
17547
17548 // if(version > 0x192)
17549 // {
17550 // //section version info
17551 // if(!p_igetw(&section_version,f,true))
17552 // {
17553 // return qe_invalid;
17554 // }
17555
17556 // FFCore.quest_format[vCombos] = section_version;
17557
17558 // //al_trace("Combos version %d\n", section_version);
17559 // if(!p_igetw(&section_cversion,f,true))
17560 // {
17561 // return qe_invalid;
17562 // }
17563
17564 // //section size
17565 // if(!p_igetl(&dummy,f,true))
17566 // {
17567 // return qe_invalid;
17568 // }
17569 // }
17570
17571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(version < 0x174)
17572 {
17573 combos_used=1024;
17574 }
17575
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 81 times.
83 else if(version < 0x191)
17576 {
17577 2 combos_used=2048;
17578 2 }
17579 else
17580 {
17581
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 if(!p_igetw(&combos_used,f,true))
17582 {
17583 return qe_invalid;
17584 }
17585 }
17586
17587 //finally... section data
17588
2/2
✓ Branch 0 taken 473417 times.
✓ Branch 1 taken 83 times.
473500 for(int32_t i=0; i<combos_used; i++)
17589 {
17590 473417 temp_combo.clear();
17591
17592
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 404533 times.
473417 if ( section_version >= 11 )
17593 {
17594
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.tile,f,true))
17595 {
17596 return qe_invalid;
17597 }
17598 68884 }
17599 else
17600 {
17601
1/2
✓ Branch 0 taken 404533 times.
✗ Branch 1 not taken.
404533 if(!p_igetw(&temp_combo.tile,f,true))
17602 {
17603 return qe_invalid;
17604 }
17605 }
17606 473417 temp_combo.o_tile = temp_combo.tile;
17607
1/2
✓ Branch 0 taken 473417 times.
✗ Branch 1 not taken.
473417 if(!p_getc(&temp_combo.flip,f,true))
17608 {
17609 return qe_invalid;
17610 }
17611
17612
1/2
✓ Branch 0 taken 473417 times.
✗ Branch 1 not taken.
473417 if(!p_getc(&temp_combo.walk,f,true))
17613 {
17614 return qe_invalid;
17615 }
17616
17617
1/2
✓ Branch 0 taken 473417 times.
✗ Branch 1 not taken.
473417 if(!p_getc(&temp_combo.type,f,true))
17618 {
17619 return qe_invalid;
17620 }
17621
17622
1/2
✓ Branch 0 taken 473417 times.
✗ Branch 1 not taken.
473417 if(!p_getc(&temp_combo.csets,f,true))
17623 {
17624 return qe_invalid;
17625 }
17626
17627
2/2
✓ Branch 0 taken 469321 times.
✓ Branch 1 taken 4096 times.
473417 if(version < 0x193)
17628 {
17629
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_getc(&padding,f,true))
17630 return qe_invalid;
17631
17632
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(!p_getc(&padding,f,true))
17633 return qe_invalid;
17634
17635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4096 times.
4096 if(version < 0x192)
17636 {
17637
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(version == 0x191)
17638 {
17639 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17640 {
17641 if(!p_getc(&padding,f,true))
17642 return qe_invalid;
17643 }
17644 }
17645 4096 }
17646 4096 }
17647
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 469321 times.
473417 if(version >= 0x192)
17648 {
17649
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(!p_getc(&temp_combo.frames,f,true))
17650 return qe_invalid;
17651
17652
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(!p_getc(&temp_combo.speed,f,true))
17653 return qe_invalid;
17654
17655
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(!p_igetw(&temp_combo.nextcombo,f,true))
17656 return qe_invalid;
17657
17658
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(!p_getc(&temp_combo.nextcset,f,true))
17659 return qe_invalid;
17660
17661 //Base flag
17662
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 360207 times.
469321 if(section_version>=3)
17663
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.flag,f,true))
17664 return qe_invalid;
17665
17666
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 360207 times.
469321 if(section_version>=4)
17667 {
17668
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanim,f,true))
17669 return qe_invalid;
17670
17671
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_igetw(&temp_combo.nexttimer,f,true))
17672 return qe_invalid;
17673 360207 }
17674
17675
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 360207 times.
469321 if(section_version>=5)
17676
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.skipanimy,f,true))
17677 return qe_invalid;
17678
17679
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 360207 times.
469321 if(section_version>=6)
17680 {
17681
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(!p_getc(&temp_combo.animflags,f,true))
17682 return qe_invalid;
17683
17684
1/2
✓ Branch 0 taken 360207 times.
✗ Branch 1 not taken.
360207 if(section_version == 6)
17685 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17686 360207 }
17687
17688
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=8) //combo Attributes[4] and userflags.
17689 {
17690
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17691
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f,true))
17692 return qe_invalid;
17693
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f,true))
17694 return qe_invalid;
17695
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(section_version >= 20)
17696
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f,true))
17697 return qe_invalid;
17698 68884 }
17699
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 400437 times.
469321 if(section_version>=10) //combo trigger flags
17700 {
17701
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17702
1/2
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17703 return qe_invalid;
17704 68884 }
17705
1/2
✓ Branch 0 taken 400437 times.
✗ Branch 1 not taken.
400437 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17706 {
17707 for ( int32_t q = 0; q < 2; q++ )
17708 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
17709 return qe_invalid;
17710 }
17711
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version >= 9)
17712
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f,true))
17713 return qe_invalid;
17714
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version >= 22)
17715
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f,true))
17716 return qe_invalid;
17717
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 24)
17718 {
17719 if(!p_getc(&temp_combo.triggeritem,f,true))
17720 return qe_invalid;
17721 if(!p_getc(&temp_combo.trigtimer,f,true))
17722 return qe_invalid;
17723 }
17724
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 25)
17725 if(!p_getc(&temp_combo.trigsfx,f,true))
17726 return qe_invalid;
17727
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 27)
17728 if(!p_igetl(&temp_combo.trigchange,f,true))
17729 return qe_invalid;
17730
17731
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 29)
17732 {
17733 if(!p_igetw(&temp_combo.trigprox,f,true))
17734 return qe_invalid;
17735 if(!p_getc(&temp_combo.trigctr,f,true))
17736 return qe_invalid;
17737 if(!p_igetl(&temp_combo.trigctramnt,f,true))
17738 return qe_invalid;
17739 }
17740
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 30)
17741 if(!p_getc(&temp_combo.triglbeam,f,true))
17742 return qe_invalid;
17743
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 31)
17744 {
17745 if(!p_getc(&temp_combo.trigcschange,f,true))
17746 return qe_invalid;
17747 if(!p_igetw(&temp_combo.spawnitem,f,true))
17748 return qe_invalid;
17749 if(!p_igetw(&temp_combo.spawnenemy,f,true))
17750 return qe_invalid;
17751 if(!p_getc(&temp_combo.exstate,f,true))
17752 return qe_invalid;
17753 if(!p_igetl(&temp_combo.spawnip,f,true))
17754 return qe_invalid;
17755 if(!p_getc(&temp_combo.trigcopycat,f,true))
17756 return qe_invalid;
17757 }
17758
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(section_version >= 32)
17759 if(!p_getc(&temp_combo.trigcooldown,f,true))
17760 return qe_invalid;
17761
17762
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=12) //combo label
17763
2/2
✓ Branch 0 taken 757724 times.
✓ Branch 1 taken 68884 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17764
1/2
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
757724 if(!p_getc(&temp_combo.label[q],f,true))
17765 68884 return qe_invalid;
17766
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=13) //attribytes[4]
17767
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17768
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17769 68884 return qe_invalid;
17770 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17771 * This fixes a poor implementation of a ->next flag bug thing.
17772 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17773 * there was a version bump a few weeks before a change that broke stuff.
17774 */
17775
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 400437 times.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
469321 if (section_version >= 13 && section_version < 21)
17776 {
17777 set_bit(quest_rules,qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17778 }
17779 //combo scripts
17780
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=14)
17781 {
17782
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetw(&temp_combo.script,f,true))
17783 return qe_invalid;
17784
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17785
1/2
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f,true))
17786 return qe_invalid;
17787 68884 }
17788 //al_trace("Read combo script data\n");
17789
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=15)
17790 {
17791
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f,true)) return qe_invalid;
17792
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17793
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f,true)) return qe_invalid;
17794
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68884 times.
68884 if(!p_getc(&temp_combo.aclk,f,true)) return qe_invalid;
17795 68884 }
17796
2/2
✓ Branch 0 taken 400437 times.
✓ Branch 1 taken 68884 times.
469321 if(section_version>=17) //attribytes[4]
17797 {
17798
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17799
1/2
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f,true))
17800 return qe_invalid;
17801
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17802
1/2
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
17803 return qe_invalid;
17804 68884 }
17805
17806
1/2
✓ Branch 0 taken 469321 times.
✗ Branch 1 not taken.
469321 if(version < 0x193)
17807 for(int32_t q=0; q<11; q++)
17808 if(!p_getc(&dummy,f,true))
17809 return qe_invalid;
17810 469321 }
17811
17812 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17813
3/6
✓ Branch 0 taken 360207 times.
✓ Branch 1 taken 113210 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 360207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
473417 if((version < 0x211)||((version == 0x211)&&(build<7)))
17814 {
17815
2/2
✓ Branch 0 taken 109114 times.
✓ Branch 1 taken 4096 times.
113210 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
17816 {
17817
1/5
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
4096 switch(temp_combo.tile)
17818 {
17819 case 130:
17820 temp_combo.tile = 132;
17821 break;
17822
17823 case 131:
17824 temp_combo.tile = 133;
17825 break;
17826
17827 case 132:
17828 temp_combo.tile = 130;
17829 break;
17830
17831 case 133:
17832 temp_combo.tile = 131;
17833 break;
17834 }
17835 4096 }
17836 113210 }
17837
17838
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 404533 times.
473417 if(section_version < 15)
17839 404533 temp_combo.o_tile = temp_combo.tile;
17840
17841
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 404533 times.
473417 if(section_version<18) //upper bits for .walk
17842 404533 temp_combo.walk |= 0xF0;
17843
17844
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 404533 times.
473417 if(section_version < 19)
17845
2/2
✓ Branch 0 taken 1618132 times.
✓ Branch 1 taken 404533 times.
2022665 for(int32_t q = 0; q < 4; ++q)
17846 2022665 temp_combo.attributes[q] *= 10000L;
17847
17848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(section_version < 23)
17849 {
17850
2/2
✓ Branch 0 taken 148 times.
✓ Branch 1 taken 473269 times.
473417 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17851 {
17852 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17853 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17854 case cTRIGGERGENERIC: case cCSWITCH:
17855 148 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17856 148 }
17857 473417 }
17858
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(section_version < 25)
17859 {
17860
2/2
✓ Branch 0 taken 2635 times.
✓ Branch 1 taken 470782 times.
473417 switch(temp_combo.type)
17861 {
17862 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17863
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2635 times.
2635 if(!(temp_combo.usrflags & cflag3))
17864 2635 temp_combo.attribytes[3] = WAV_DOOR;
17865 2635 temp_combo.usrflags &= ~cflag3;
17866 2635 break;
17867 }
17868 473417 }
17869
17870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(section_version < 26)
17871
2/2
✓ Branch 0 taken 472900 times.
✓ Branch 1 taken 517 times.
473934 if(temp_combo.type == cARMOS)
17872
1/2
✓ Branch 0 taken 517 times.
✗ Branch 1 not taken.
517 if(temp_combo.usrflags & cflag1)
17873 temp_combo.usrflags |= cflag3;
17874
17875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(section_version < 27)
17876 {
17877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17878 temp_combo.trigchange = 1;
17879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17880 temp_combo.trigchange = -1;
17881 473417 else temp_combo.trigchange = 0;
17882 473417 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17883 473417 }
17884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 473417 times.
473417 if(section_version < 28)
17885 {
17886
2/2
✓ Branch 0 taken 1396 times.
✓ Branch 1 taken 472021 times.
473417 switch(temp_combo.type)
17887 {
17888 case cLOCKBLOCK: case cLOCKEDCHEST:
17889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1396 times.
1396 if(temp_combo.usrflags & cflag7)
17890 temp_combo.usrflags |= cflag8;
17891 1396 else temp_combo.usrflags &= ~cflag8;
17892 1396 temp_combo.usrflags &= ~cflag7;
17893 1396 break;
17894 }
17895
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 473348 times.
473417 switch(temp_combo.type)
17896 {
17897 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17898 69 temp_combo.attrishorts[2] = -1;
17899 69 temp_combo.usrflags |= cflag7;
17900 69 break;
17901 }
17902 473417 }
17903
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 404533 times.
473417 if(section_version < 20)
17904 {
17905 404533 temp_combo.genflags = 0;
17906
2/2
✓ Branch 0 taken 17367 times.
✓ Branch 1 taken 387166 times.
404533 switch(temp_combo.type)
17907 {
17908 case cPUSH_WAIT: case cPUSH_HEAVY:
17909 case cPUSH_HW: case cL_STATUE:
17910 case cR_STATUE: case cPUSH_HEAVY2:
17911 case cPUSH_HW2: case cPOUND:
17912 case cC_STATUE: case cMIRROR:
17913 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17914 case cMAGICPRISM: case cMAGICPRISM4:
17915 case cMAGICSPONGE: case cEYEBALL_A:
17916 case cEYEBALL_B: case cEYEBALL_4:
17917 case cBUSH: case cFLOWERS:
17918 case cLOCKBLOCK: case cLOCKBLOCK2:
17919 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17920 case cCHEST: case cCHEST2:
17921 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17922 case cBOSSCHEST: case cBOSSCHEST2:
17923 case cBUSHNEXT: case cBUSHTOUCHY:
17924 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17925 case cSIGNPOST: case cCSWITCHBLOCK:
17926 case cTORCH: case cTRIGGERGENERIC:
17927
1/2
✓ Branch 0 taken 17367 times.
✗ Branch 1 not taken.
17367 if(temp_combo.usrflags & cflag16)
17928 {
17929 temp_combo.genflags |= cflag1;
17930 temp_combo.usrflags &= ~cflag16;
17931 }
17932 17367 break;
17933 }
17934 404533 }
17935
17936
2/4
✓ Branch 0 taken 473417 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 473417 times.
473417 if(keepdata==true && i>=start_combo)
17937 {
17938 473417 combobuf[i] = temp_combo;
17939 473417 }
17940 473417 }
17941
17942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(keepdata==true)
17943 {
17944
3/6
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
83 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17945 {
17946
2/2
✓ Branch 0 taken 130560 times.
✓ Branch 1 taken 2 times.
130562 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17947 {
17948
1/2
✓ Branch 0 taken 130560 times.
✗ Branch 1 not taken.
130560 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17949 {
17950 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17951 }
17952 130560 }
17953 2 }
17954
17955 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17956
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 78 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
83 if(version == 0x210 && !is_zquest())
17957 {
17958
2/2
✓ Branch 0 taken 326400 times.
✓ Branch 1 taken 5 times.
326405 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17959
2/2
✓ Branch 0 taken 326398 times.
✓ Branch 1 taken 2 times.
326402 if(combobuf[tmpcounter].type == cLADDERONLY)
17960 2 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17961 5 }
17962
17963
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 7 times.
83 if(section_version<7)
17964 {
17965
2/2
✓ Branch 0 taken 456960 times.
✓ Branch 1 taken 7 times.
456967 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17966 {
17967
6/9
✓ Branch 0 taken 456823 times.
✓ Branch 1 taken 57 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 28 times.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
456960 switch(combobuf[tmpcounter].type)
17968 {
17969 case cSLASH:
17970 57 combobuf[tmpcounter].type=cSLASHTOUCHY;
17971 57 break;
17972
17973 case cSLASHITEM:
17974 32 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17975 32 break;
17976
17977 case cBUSH:
17978 28 combobuf[tmpcounter].type=cBUSHTOUCHY;
17979 28 break;
17980
17981 case cFLOWERS:
17982 10 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17983 10 break;
17984
17985 case cTALLGRASS:
17986 10 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17987 10 break;
17988
17989 case cSLASHNEXT:
17990 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17991 break;
17992
17993 case cSLASHNEXTITEM:
17994 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17995 break;
17996
17997 case cBUSHNEXT:
17998 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17999 break;
18000 }
18001 456960 }
18002 7 }
18003
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 81 times.
83 if (section_version < 16)
18004 {
18005
2/2
✓ Branch 0 taken 5287680 times.
✓ Branch 1 taken 81 times.
5287761 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18006 {
18007
2/2
✓ Branch 0 taken 5282437 times.
✓ Branch 1 taken 5243 times.
5287680 if (combobuf[tmpcounter].type == cWATER)
18008 {
18009 5243 combobuf[tmpcounter].attributes[0] = 40000L;
18010 5243 }
18011 5287680 }
18012 81 }
18013
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1 times.
83 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18014 {
18015 1 combobuf[0].walk = 0xF0;
18016 1 combobuf[0].type = 0;
18017 1 combobuf[0].flag = 0;
18018 1 }
18019 83 }
18020
18021 //Now for the new combo alias reset
18022
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
83 if(section_version<2 && keepdata)
18023 {
18024
2/2
✓ Branch 0 taken 57344 times.
✓ Branch 1 taken 7 times.
57351 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18025 {
18026 57344 combo_aliases[j].width = 0;
18027 57344 combo_aliases[j].height = 0;
18028 57344 combo_aliases[j].layermask = 0;
18029
18030
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(combo_aliases[j].combos != NULL)
18031 {
18032
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 delete[] combo_aliases[j].combos;
18033 57344 }
18034
18035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57344 times.
57344 if(combo_aliases[j].csets != NULL)
18036 {
18037
1/2
✓ Branch 0 taken 57344 times.
✗ Branch 1 not taken.
57344 delete[] combo_aliases[j].csets;
18038 57344 }
18039
18040 57344 combo_aliases[j].combos = new word[1];
18041 57344 combo_aliases[j].csets = new byte[1];
18042 57344 combo_aliases[j].combos[0] = 0;
18043 57344 combo_aliases[j].csets[0] = 0;
18044 57344 }
18045 7 }
18046
18047
18048 83 setup_combo_animations();
18049 83 setup_combo_animations2();
18050 83 return 0;
18051 83 }
18052 136622 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18053 {
18054 byte combo_has_flags;
18055
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136622 times.
136622 if(!p_getc(&combo_has_flags,f,true))
18056 return qe_invalid;
18057
18058 136622 temp_combo.clear();
18059
2/2
✓ Branch 0 taken 88328 times.
✓ Branch 1 taken 48294 times.
136622 if(combo_has_flags)
18060 {
18061
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 48291 times.
48294 if(combo_has_flags&CHAS_GENERAL)
18062 {
18063
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_igetl(&temp_combo.tile,f,true))
18064 {
18065 return qe_invalid;
18066 }
18067 48291 temp_combo.o_tile = temp_combo.tile;
18068
18069
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_getc(&temp_combo.flip,f,true))
18070 {
18071 return qe_invalid;
18072 }
18073
18074
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_getc(&temp_combo.walk,f,true))
18075 {
18076 return qe_invalid;
18077 }
18078
18079
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_getc(&temp_combo.type,f,true))
18080 {
18081 return qe_invalid;
18082 }
18083
18084
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_getc(&temp_combo.flag,f,true))
18085 {
18086 return qe_invalid;
18087 }
18088
18089
1/2
✓ Branch 0 taken 48291 times.
✗ Branch 1 not taken.
48291 if(!p_getc(&temp_combo.csets,f,true))
18090 {
18091 return qe_invalid;
18092 }
18093 48291 }
18094
2/2
✓ Branch 0 taken 48278 times.
✓ Branch 1 taken 16 times.
48294 if(combo_has_flags&CHAS_SCRIPT)
18095 {
18096
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 16 times.
192 for ( int32_t q = 0; q < 11; q++ )
18097 {
18098
1/2
✓ Branch 0 taken 176 times.
✗ Branch 1 not taken.
176 if(!p_getc(&temp_combo.label[q],f,true))
18099 {
18100 return qe_invalid;
18101 }
18102 176 }
18103
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_combo.script,f,true)) return qe_invalid;
18104
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 16 times.
48 for ( int32_t q = 0; q < 2; q++ )
18105 {
18106
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_igetl(&temp_combo.initd[q],f,true))
18107 {
18108 return qe_invalid;
18109 }
18110 32 }
18111 16 }
18112
2/2
✓ Branch 0 taken 34981 times.
✓ Branch 1 taken 13313 times.
48294 if(combo_has_flags&CHAS_ANIM)
18113 {
18114
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.frames,f,true))
18115 {
18116 return qe_invalid;
18117 }
18118
18119
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.speed,f,true))
18120 {
18121 return qe_invalid;
18122 }
18123
18124
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_igetw(&temp_combo.nextcombo,f,true))
18125 {
18126 return qe_invalid;
18127 }
18128
18129
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.nextcset,f,true))
18130 {
18131 return qe_invalid;
18132 }
18133
18134
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.skipanim,f,true))
18135 {
18136 return qe_invalid;
18137 }
18138
18139
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.skipanimy,f,true))
18140 {
18141 return qe_invalid;
18142 }
18143
18144
1/2
✓ Branch 0 taken 13313 times.
✗ Branch 1 not taken.
13313 if(!p_getc(&temp_combo.animflags,f,true))
18145 {
18146 return qe_invalid;
18147 }
18148 13313 }
18149
2/2
✓ Branch 0 taken 44015 times.
✓ Branch 1 taken 4279 times.
48294 if(combo_has_flags&CHAS_ATTRIB)
18150 {
18151
2/2
✓ Branch 0 taken 17116 times.
✓ Branch 1 taken 4279 times.
21395 for ( int32_t q = 0; q < 4; q++ )
18152 {
18153
1/2
✓ Branch 0 taken 17116 times.
✗ Branch 1 not taken.
17116 if(!p_igetl(&temp_combo.attributes[q],f,true))
18154 {
18155 return qe_invalid;
18156 }
18157 17116 }
18158
2/2
✓ Branch 0 taken 34232 times.
✓ Branch 1 taken 4279 times.
38511 for ( int32_t q = 0; q < 8; q++ )
18159 {
18160
1/2
✓ Branch 0 taken 34232 times.
✗ Branch 1 not taken.
34232 if(!p_getc(&temp_combo.attribytes[q],f,true))
18161 {
18162 return qe_invalid;
18163 }
18164 34232 }
18165
2/2
✓ Branch 0 taken 34232 times.
✓ Branch 1 taken 4279 times.
38511 for ( int32_t q = 0; q < 8; q++ )
18166 {
18167
1/2
✓ Branch 0 taken 34232 times.
✗ Branch 1 not taken.
34232 if(!p_igetw(&temp_combo.attrishorts[q],f,true))
18168 {
18169 return qe_invalid;
18170 }
18171 34232 }
18172 4279 }
18173
2/2
✓ Branch 0 taken 46935 times.
✓ Branch 1 taken 1359 times.
48294 if(combo_has_flags&CHAS_FLAG)
18174 {
18175
1/2
✓ Branch 0 taken 1359 times.
✗ Branch 1 not taken.
1359 if(!p_igetl(&temp_combo.usrflags,f,true))
18176 {
18177 return qe_invalid;
18178 }
18179
1/2
✓ Branch 0 taken 1359 times.
✗ Branch 1 not taken.
1359 if(!p_igetw(&temp_combo.genflags,f,true))
18180 {
18181 return qe_invalid;
18182 }
18183 1359 }
18184
2/2
✓ Branch 0 taken 47958 times.
✓ Branch 1 taken 336 times.
48294 if(combo_has_flags&CHAS_TRIG)
18185 {
18186 336 int numtrigs = s_version < 36 ? 3 : 6;
18187
2/2
✓ Branch 0 taken 1008 times.
✓ Branch 1 taken 336 times.
1344 for ( int32_t q = 0; q < numtrigs; q++ )
18188 {
18189
1/2
✓ Branch 0 taken 1008 times.
✗ Branch 1 not taken.
1008 if(!p_igetl(&temp_combo.triggerflags[q],f,true))
18190 {
18191 return qe_invalid;
18192 }
18193 1008 }
18194
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&temp_combo.triggerlevel,f,true))
18195 {
18196 return qe_invalid;
18197 }
18198
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.triggerbtn,f,true))
18199 {
18200 return qe_invalid;
18201 }
18202
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.triggeritem,f,true))
18203 {
18204 return qe_invalid;
18205 }
18206
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigtimer,f,true))
18207 {
18208 return qe_invalid;
18209 }
18210
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigsfx,f,true))
18211 {
18212 return qe_invalid;
18213 }
18214
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&temp_combo.trigchange,f,true))
18215 {
18216 return qe_invalid;
18217 }
18218
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&temp_combo.trigprox,f,true))
18219 {
18220 return qe_invalid;
18221 }
18222
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigctr,f,true))
18223 {
18224 return qe_invalid;
18225 }
18226
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&temp_combo.trigctramnt,f,true))
18227 {
18228 return qe_invalid;
18229 }
18230
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.triglbeam,f,true))
18231 {
18232 return qe_invalid;
18233 }
18234
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigcschange,f,true))
18235 {
18236 return qe_invalid;
18237 }
18238
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&temp_combo.spawnitem,f,true))
18239 {
18240 return qe_invalid;
18241 }
18242
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&temp_combo.spawnenemy,f,true))
18243 {
18244 return qe_invalid;
18245 }
18246
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.exstate,f,true))
18247 {
18248 return qe_invalid;
18249 }
18250
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetl(&temp_combo.spawnip,f,true))
18251 {
18252 return qe_invalid;
18253 }
18254
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigcopycat,f,true))
18255 {
18256 return qe_invalid;
18257 }
18258
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.trigcooldown,f,true))
18259 {
18260 return qe_invalid;
18261 }
18262
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
336 if(s_version >= 35)
18263 {
18264
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&temp_combo.prompt_cid,f,true))
18265 {
18266 return qe_invalid;
18267 }
18268
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_getc(&temp_combo.prompt_cs,f,true))
18269 {
18270 return qe_invalid;
18271 }
18272
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(!p_igetw(&temp_combo.prompt_x,f,true))
18273 {
18274 return qe_invalid;
18275 }
18276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 336 times.
336 if(!p_igetw(&temp_combo.prompt_y,f,true))
18277 {
18278 return qe_invalid;
18279 }
18280 336 }
18281
1/2
✓ Branch 0 taken 336 times.
✗ Branch 1 not taken.
336 if(s_version >= 36)
18282 {
18283 if(!p_getc(&temp_combo.trig_lstate,f,true))
18284 {
18285 return qe_invalid;
18286 }
18287 if(!p_getc(&temp_combo.trig_gstate,f,true))
18288 {
18289 return qe_invalid;
18290 }
18291 if(!p_igetl(&temp_combo.trig_statetime,f,true))
18292 {
18293 return qe_invalid;
18294 }
18295 }
18296 336 }
18297
2/2
✓ Branch 0 taken 48215 times.
✓ Branch 1 taken 79 times.
48294 if(combo_has_flags&CHAS_LIFT)
18298 {
18299
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&temp_combo.liftcmb,f,true))
18300 return qe_invalid;
18301
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftcs,f,true))
18302 return qe_invalid;
18303
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&temp_combo.liftundercmb,f,true))
18304 return qe_invalid;
18305
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftundercs,f,true))
18306 return qe_invalid;
18307
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftdmg,f,true))
18308 return qe_invalid;
18309
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftlvl,f,true))
18310 return qe_invalid;
18311
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftitm,f,true))
18312 return qe_invalid;
18313
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftflags,f,true))
18314 return qe_invalid;
18315
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftgfx,f,true))
18316 return qe_invalid;
18317
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftsprite,f,true))
18318 return qe_invalid;
18319
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftsfx,f,true))
18320 return qe_invalid;
18321
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&temp_combo.liftbreaksprite,f,true))
18322 return qe_invalid;
18323
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.liftbreaksfx,f,true))
18324 return qe_invalid;
18325
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
79 if(s_version >= 34)
18326 {
18327
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.lifthei,f,true))
18328 return qe_invalid;
18329
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_getc(&temp_combo.lifttime,f,true))
18330 return qe_invalid;
18331 79 }
18332 79 }
18333 48294 }
18334 136622 return 0;
18335 136622 }
18336 104 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos, bool keepdata)
18337 {
18338 104 word section_version=0;
18339 104 word section_cversion=0;
18340 104 word combos_used=0;
18341 int32_t dummy;
18342 byte padding;
18343 104 newcombo temp_combo;
18344
18345 104 reset_combo_animations();
18346 104 reset_combo_animations2();
18347 104 init_combo_classes();
18348
18349
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true) //reset combos
18350 {
18351
2/2
✓ Branch 0 taken 6789120 times.
✓ Branch 1 taken 104 times.
6789224 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18352 6789120 combobuf[q].clear();
18353 104 }
18354
18355
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(version > 0x192) //Version info
18356 {
18357
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&section_version,f,true))
18358 {
18359 return qe_invalid;
18360 }
18361 102 FFCore.quest_format[vCombos] = section_version;
18362
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&section_cversion,f,true))
18363 {
18364 return qe_invalid;
18365 }
18366
18367 //section size
18368
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
18369 {
18370 return qe_invalid;
18371 }
18372 102 }
18373
18374
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(section_version > 32) //Cleanup time!
18375 {
18376
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!p_igetw(&combos_used,f,true))
18377 {
18378 return qe_invalid;
18379 }
18380
2/2
✓ Branch 0 taken 136622 times.
✓ Branch 1 taken 21 times.
136643 for(int32_t i=0; i<combos_used; i++)
18381 {
18382 136622 auto ret = readcombo_loop(f,section_version,temp_combo);
18383
1/2
✓ Branch 0 taken 136622 times.
✗ Branch 1 not taken.
136622 if(ret) return ret;
18384
2/4
✓ Branch 0 taken 136622 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 136622 times.
136622 if(keepdata==true && i>=start_combo)
18385 136622 memcpy(&combobuf[i], &temp_combo, sizeof(temp_combo));
18386 136622 }
18387 21 }
18388 else //Call the old function for all old versions
18389 {
18390 83 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos,keepdata);
18391
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if(ret) return ret; //error, end read
18392 }
18393
18394
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(keepdata && false/*section_version < 34*/)
18395 {
18396 for(int32_t i=start_combo; i<combos_used; i++)
18397 {
18398 newcombo& cmb = combobuf[i];
18399 //Do anything to 'cmb' needed for version handling
18400 }
18401 }
18402
18403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
18404 {
18405
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 83 times.
104 if(!get_bit(quest_rules,qr_ALLOW_EDITING_COMBO_0))
18406 {
18407 21 combobuf[0].walk = 0xF0;
18408 21 combobuf[0].type = 0;
18409 21 combobuf[0].flag = 0;
18410 21 }
18411 104 }
18412
18413 104 setup_combo_animations();
18414 104 setup_combo_animations2();
18415 104 return 0;
18416 104 }
18417
18418 97 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build, bool keepdata)
18419 {
18420 //these are here to bypass compiler warnings about unused arguments
18421 97 Header=Header;
18422 97 version=version;
18423 97 build=build;
18424
18425 int32_t dummy;
18426 97 word sversion=0, c_sversion;
18427
18428 //section version info
18429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&sversion,f,true))
18430 {
18431 return qe_invalid;
18432 }
18433
18434 97 FFCore.quest_format[vComboAliases] = sversion;
18435
18436 //al_trace("Combo aliases version %d\n", sversion);
18437
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&c_sversion,f,true))
18438 {
18439 return qe_invalid;
18440 }
18441
18442 //section size
18443
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy,f,true))
18444 {
18445 return qe_invalid;
18446 }
18447
18448 97 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18449
18450
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 74 times.
97 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18451 {
18452 74 max_num_combo_aliases = MAX250COMBOALIASES;
18453 74 }
18454
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18455 {
18456 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18457 }
18458
18459
2/2
✓ Branch 0 taken 339968 times.
✓ Branch 1 taken 97 times.
340065 for(int32_t j=0; j<max_num_combo_aliases; j++)
18460 {
18461 byte width,height,mask,tempcset;
18462 int32_t count;
18463 word tempword;
18464 byte tempbyte;
18465
18466
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(!p_igetw(&tempword,f,true))
18467 {
18468 return qe_invalid;
18469 }
18470
18471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339968 times.
339968 if(keepdata)
18472 {
18473 339968 combo_aliases[j].combo = tempword;
18474 339968 }
18475
18476
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(!p_getc(&tempbyte,f,true))
18477 {
18478 return qe_invalid;
18479 }
18480
18481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339968 times.
339968 if(keepdata)
18482 {
18483 339968 combo_aliases[j].cset = tempbyte;
18484 339968 }
18485
18486
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(!p_getc(&width,f,true))
18487 {
18488 return qe_invalid;
18489 }
18490
18491
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(!p_getc(&height,f,true))
18492 {
18493 return qe_invalid;
18494 }
18495
18496
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(!p_getc(&mask,f,true))
18497 {
18498 return qe_invalid;
18499 }
18500
18501 339968 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18502
18503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339968 times.
339968 if(keepdata)
18504 {
18505
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(combo_aliases[j].combos != NULL)
18506 {
18507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339968 times.
339968 delete[] combo_aliases[j].combos;
18508 339968 }
18509
18510
1/2
✓ Branch 0 taken 339968 times.
✗ Branch 1 not taken.
339968 if(combo_aliases[j].csets != NULL)
18511 {
18512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339968 times.
339968 delete[] combo_aliases[j].csets;
18513 339968 }
18514
18515 339968 combo_aliases[j].width = width;
18516 339968 combo_aliases[j].height = height;
18517 339968 combo_aliases[j].layermask = mask;
18518 339968 combo_aliases[j].combos = new word[count];
18519 339968 combo_aliases[j].csets = new byte[count];
18520 339968 }
18521
18522
2/2
✓ Branch 0 taken 348205 times.
✓ Branch 1 taken 339968 times.
688173 for(int32_t k=0; k<count; k++)
18523 {
18524
1/2
✓ Branch 0 taken 348205 times.
✗ Branch 1 not taken.
348205 if(!p_igetw(&tempword,f,true))
18525 {
18526 return qe_invalid;
18527 }
18528
18529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348205 times.
348205 if(keepdata)
18530 {
18531 348205 combo_aliases[j].combos[k] = tempword;
18532 348205 }
18533 348205 }
18534
18535
2/2
✓ Branch 0 taken 348205 times.
✓ Branch 1 taken 339968 times.
688173 for(int32_t k=0; k<count; k++)
18536 {
18537
1/2
✓ Branch 0 taken 348205 times.
✗ Branch 1 not taken.
348205 if(!p_getc(&tempcset,f,true))
18538 {
18539 return qe_invalid;
18540 }
18541
18542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 348205 times.
348205 if(keepdata)
18543 {
18544 348205 combo_aliases[j].csets[k] = tempcset;
18545 348205 }
18546 348205 }
18547 339968 }
18548
18549 97 word num_combo_pools = 0;
18550
2/2
✓ Branch 0 taken 76 times.
✓ Branch 1 taken 21 times.
97 if(sversion >= 4)
18551 {
18552
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 if(!p_igetw(&num_combo_pools,f,true))
18553 {
18554 return qe_invalid;
18555 }
18556 21 }
18557
18558
2/2
✓ Branch 0 taken 794624 times.
✓ Branch 1 taken 97 times.
794721 for(combo_pool& pool : combo_pools)
18559 {
18560 794624 pool.clear();
18561 }
18562
18563 97 combo_pool temp_cpool;
18564
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 97 times.
154 for(word cp = 0; cp < num_combo_pools; ++cp)
18565 {
18566 57 int32_t num_combos_in_pool = 0;
18567
2/4
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57 times.
✗ Branch 3 not taken.
57 if(!p_igetl(&num_combos_in_pool,f,true))
18568 {
18569 return qe_invalid;
18570 }
18571
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(num_combos_in_pool < 1) continue; //nothing to read
18572
18573
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 temp_cpool.clear();
18574
18575 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18576
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 57 times.
304 for(auto q = 0; q < num_combos_in_pool; ++q)
18577 {
18578
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_igetl(&cp_cid,f,true))
18579 {
18580 return qe_invalid;
18581 }
18582
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_getc(&cp_cs,f,true))
18583 {
18584 return qe_invalid;
18585 }
18586
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(!p_igetw(&cp_quant,f,true))
18587 {
18588 return qe_invalid;
18589 }
18590
1/2
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
247 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18591 247 }
18592
18593
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 if(keepdata)
18594 {
18595
1/2
✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
57 combo_pools[cp] = temp_cpool;
18596 57 }
18597 57 }
18598
18599 97 return 0;
18600 97 }
18601
18602 104 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets, bool keepdata)
18603 {
18604 //these are here to bypass compiler warnings about unused arguments
18605
18606 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18607 //Capitalized cause it'll save you a headache. -Deedee
18608 104 start_cset=start_cset;
18609 104 max_csets=max_csets;
18610 104 word s_version=0;
18611
18612 miscQdata temp_misc;
18613 104 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18614
18615 byte temp_colordata[48];
18616 char temp_palname[PALNAMESIZE];
18617
18618 int32_t dummy;
18619 word palcycles;
18620
18621
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(version > 0x192)
18622 {
18623 //section version info
18624
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
18625 {
18626 return qe_invalid;
18627 }
18628
18629 102 FFCore.quest_format[vCSets] = s_version;
18630
18631 //al_trace("Color data version %d\n", s_version);
18632
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy,f,true))
18633 {
18634 return qe_invalid;
18635 }
18636
18637 //section size
18638
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
18639 {
18640 return qe_invalid;
18641 }
18642 102 }
18643
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if (s_version < 5)
18644 {
18645
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 79 times.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
81 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18646
18647 //finally... section data
18648 81 int32_t q = 0;
18649 81 int32_t p = -15;
18650
2/2
✓ Branch 0 taken 19440 times.
✓ Branch 1 taken 81 times.
19521 for(int32_t i=0; i<oldpdTOTAL; ++i)
18651 {
18652 19440 memset(temp_colordata, 0, 48);
18653
18654
1/2
✓ Branch 0 taken 19440 times.
✗ Branch 1 not taken.
19440 if(!pfread(temp_colordata,48,f,true))
18655 {
18656 return qe_invalid;
18657 }
18658
18659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19440 times.
19440 if(keepdata==true)
18660 {
18661 19440 memcpy(&colordata[q*48], temp_colordata, 48);
18662 19440 }
18663 19440 ++q;
18664
8/8
✓ Branch 0 taken 18144 times.
✓ Branch 1 taken 1296 times.
✓ Branch 2 taken 1377 times.
✓ Branch 3 taken 16767 times.
✓ Branch 4 taken 162 times.
✓ Branch 5 taken 1215 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 158 times.
19440 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18665 {
18666
1/2
✓ Branch 0 taken 1373 times.
✗ Branch 1 not taken.
1373 if (s_version < 5) //Bumping up the size of level palettes
18667 {
18668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1373 times.
1373 if(keepdata==true)
18669 {
18670 1373 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18671 1373 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18672 1373 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18673 1373 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18674 1373 }
18675 1373 q+=4;
18676 1373 }
18677 else
18678 {
18679 for(int m = 0; m < 4; ++m)
18680 {
18681 memset(temp_colordata, 0, 48);
18682 if(!pfread(temp_colordata,48,f,true))
18683 {
18684 return qe_invalid;
18685 }
18686 if(keepdata==true)
18687 {
18688 memcpy(&colordata[q*48], temp_colordata, 48);
18689 }
18690 ++q;
18691 }
18692 }
18693 1373 }
18694 19440 ++p;
18695 19440 }
18696
18697
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 79 times.
81 if(RealOldVerion)
18698 {
18699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata==true)
18700 {
18701 2 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18702 2 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18703 2 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18704 2 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18705 2 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18706 2 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18707 2 }
18708 2 }
18709 else
18710 {
18711 79 memset(temp_colordata, 0, 48);
18712
18713
2/2
✓ Branch 0 taken 247507 times.
✓ Branch 1 taken 79 times.
247586 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18714 {
18715
1/2
✓ Branch 0 taken 247507 times.
✗ Branch 1 not taken.
247507 if(!pfread(temp_colordata,48,f,true))
18716 {
18717 return qe_invalid;
18718 }
18719
18720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247507 times.
247507 if(keepdata==true)
18721 {
18722 247507 memcpy(&colordata[q*48], temp_colordata, 48);
18723 247507 }
18724 247507 ++q;
18725
7/8
✓ Branch 0 taken 247507 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19039 times.
✓ Branch 3 taken 228468 times.
✓ Branch 4 taken 158 times.
✓ Branch 5 taken 18881 times.
✓ Branch 6 taken 148 times.
✓ Branch 7 taken 10 times.
247507 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18726 {
18727
1/2
✓ Branch 0 taken 19029 times.
✗ Branch 1 not taken.
19029 if (s_version < 5) //Bumping up the size of level palettes
18728 {
18729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19029 times.
19029 if(keepdata==true)
18730 {
18731 19029 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18732 19029 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18733 19029 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18734 19029 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18735 19029 }
18736 19029 q+=4;
18737 19029 }
18738 else
18739 {
18740 for(int m = 0; m < 4; ++m)
18741 {
18742 memset(temp_colordata, 0, 48);
18743 if(!pfread(temp_colordata,48,f,true))
18744 {
18745 return qe_invalid;
18746 }
18747 if(keepdata==true)
18748 {
18749 memcpy(&colordata[q*48], temp_colordata, 48);
18750 }
18751 ++q;
18752 }
18753 }
18754 19029 }
18755 247507 ++p;
18756 247507 }
18757
18758
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 74 times.
79 if(s_version < 4)
18759 {
18760
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(keepdata==true)
18761 {
18762 5 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18763 5 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18764 5 }
18765 5 }
18766 else
18767 {
18768
2/2
✓ Branch 0 taken 246272 times.
✓ Branch 1 taken 74 times.
246346 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18769 {
18770
1/2
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
246272 if(!pfread(temp_colordata,48,f,true))
18771 {
18772 return qe_invalid;
18773 }
18774
18775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 246272 times.
246272 if(keepdata==true)
18776 {
18777 246272 memcpy(&colordata[q*48], temp_colordata, 48);
18778 246272 }
18779 246272 ++q;
18780
5/6
✓ Branch 0 taken 246272 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18944 times.
✓ Branch 3 taken 227328 times.
✓ Branch 4 taken 148 times.
✓ Branch 5 taken 18796 times.
246272 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18781 {
18782
1/2
✓ Branch 0 taken 18796 times.
✗ Branch 1 not taken.
18796 if (s_version < 5) //Bumping up the size of level palettes
18783 {
18784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18796 times.
18796 if(keepdata==true)
18785 {
18786 18796 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18787 18796 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18788 18796 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18789 18796 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18790 18796 }
18791 18796 q+=4;
18792 18796 }
18793 else
18794 {
18795 for(int m = 0; m < 4; ++m)
18796 {
18797 memset(temp_colordata, 0, 48);
18798 if(!pfread(temp_colordata,48,f,true))
18799 {
18800 return qe_invalid;
18801 }
18802 if(keepdata==true)
18803 {
18804 memcpy(&colordata[q*48], temp_colordata, 48);
18805 }
18806 ++q;
18807 }
18808 }
18809 18796 }
18810 246272 ++p;
18811 246272 }
18812
18813 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18814 }
18815 }
18816 81 }
18817 else
18818 {
18819
2/2
✓ Branch 0 taken 201227 times.
✓ Branch 1 taken 23 times.
201250 for(int32_t i=0; i<pdTOTAL255; ++i)
18820 {
18821 201227 memset(temp_colordata, 0, 48);
18822
18823
1/2
✓ Branch 0 taken 201227 times.
✗ Branch 1 not taken.
201227 if(!pfread(temp_colordata,48,f,true))
18824 {
18825 return qe_invalid;
18826 }
18827
18828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 201227 times.
201227 if(keepdata==true)
18829 {
18830 201227 memcpy(&colordata[i*48], temp_colordata, 48);
18831 201227 }
18832 201227 }
18833 }
18834
18835
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((version < 0x192)||((version == 0x192)&&(build<76)))
18836 {
18837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata==true)
18838 {
18839 2 init_palnames();
18840 2 }
18841 2 }
18842 else
18843 {
18844 102 int32_t palnamestoread = 0;
18845
18846
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version < 3)
18847 5 palnamestoread = OLDMAXLEVELS;
18848 else
18849 97 palnamestoread = 512;
18850
18851
2/2
✓ Branch 0 taken 50944 times.
✓ Branch 1 taken 102 times.
51046 for(int32_t i=0; i<palnamestoread; ++i)
18852 {
18853 50944 memset(temp_palname, 0, PALNAMESIZE);
18854
18855
1/2
✓ Branch 0 taken 50944 times.
✗ Branch 1 not taken.
50944 if(!pfread(temp_palname,PALNAMESIZE,f,true))
18856 {
18857 return qe_invalid;
18858 }
18859
18860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50944 times.
50944 if(keepdata==true)
18861 {
18862 50944 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18863 50944 }
18864 50944 }
18865
18866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(keepdata)
18867 {
18868
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 102 times.
1382 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18869 {
18870 1280 memset(palnames[i], 0, PALNAMESIZE);
18871 1280 }
18872 102 }
18873 }
18874
18875
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(version > 0x192)
18876 {
18877
2/2
✓ Branch 0 taken 26112 times.
✓ Branch 1 taken 102 times.
26214 for(int32_t i=0; i<256; i++)
18878 {
18879
2/2
✓ Branch 0 taken 78336 times.
✓ Branch 1 taken 26112 times.
104448 for(int32_t j=0; j<3; j++)
18880 {
18881 78336 temp_misc.cycles[i][j].first=0;
18882 78336 temp_misc.cycles[i][j].count=0;
18883 78336 temp_misc.cycles[i][j].speed=0;
18884 78336 }
18885 26112 }
18886
18887
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&palcycles,f,true))
18888 {
18889 return qe_invalid;
18890 }
18891
18892
2/2
✓ Branch 0 taken 3255 times.
✓ Branch 1 taken 102 times.
3357 for(int32_t i=0; i<palcycles; i++)
18893 {
18894
2/2
✓ Branch 0 taken 9765 times.
✓ Branch 1 taken 3255 times.
13020 for(int32_t j=0; j<3; j++)
18895 {
18896
1/2
✓ Branch 0 taken 9765 times.
✗ Branch 1 not taken.
9765 if(!p_getc(&temp_misc.cycles[i][j].first,f,true))
18897 {
18898 return qe_invalid;
18899 }
18900 9765 }
18901
18902
2/2
✓ Branch 0 taken 9765 times.
✓ Branch 1 taken 3255 times.
13020 for(int32_t j=0; j<3; j++)
18903 {
18904
1/2
✓ Branch 0 taken 9765 times.
✗ Branch 1 not taken.
9765 if(!p_getc(&temp_misc.cycles[i][j].count,f,true))
18905 {
18906 return qe_invalid;
18907 }
18908 9765 }
18909
18910
2/2
✓ Branch 0 taken 9765 times.
✓ Branch 1 taken 3255 times.
13020 for(int32_t j=0; j<3; j++)
18911 {
18912
1/2
✓ Branch 0 taken 9765 times.
✗ Branch 1 not taken.
9765 if(!p_getc(&temp_misc.cycles[i][j].speed,f,true))
18913 {
18914 return qe_invalid;
18915 }
18916 9765 }
18917 3255 }
18918
18919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(keepdata==true)
18920 {
18921 102 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18922 102 }
18923 102 }
18924
18925 104 return 0;
18926 104 }
18927
18928 104 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init, bool keepdata)
18929 {
18930 104 int32_t tiles_used=0;
18931 104 word section_version = 0;
18932 104 word section_cversion = 0;
18933 104 int32_t section_size= 0;
18934 104 byte *temp_tile = new byte[tilesize(tf32Bit)];
18935
18936 //Tile Expansion
18937 //if ( version >= 0x254 && build >= 41 )
18938
3/4
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81 times.
104 if (version < 0x254 && build < 41)
18939 {
18940 //al_trace("Build was < 41 when reading tiles\n");
18941 81 max_tiles = ZC250MAXTILES;
18942 81 }
18943
18944 //al_trace("Max Tiles: %d\n", max_tiles);
18945
18946
2/6
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18947 {
18948 if(keepdata==true)
18949 {
18950 if(!init_tiles(true, Header))
18951 {
18952 al_trace("Unable to initialize tiles\n");
18953 }
18954 }
18955
18956 delete[] temp_tile;
18957 temp_tile=NULL;
18958 return 0;
18959 }
18960 else
18961 {
18962
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(version > 0x192)
18963 {
18964 //section version info
18965
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&section_version,f,true))
18966 {
18967 delete[] temp_tile;
18968 return qe_invalid;
18969 }
18970
18971 102 FFCore.quest_format[vTiles] = section_version;
18972
18973
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&section_cversion,f,true))
18974 {
18975 delete[] temp_tile;
18976 return qe_invalid;
18977 }
18978
18979 //section size
18980
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&section_size,f,true))
18981 {
18982 delete[] temp_tile;
18983 return qe_invalid;
18984 }
18985 102 }
18986
18987 //if ( build < 41 )
18988 //{
18989 // tiles_used = ZC250MAXTILES;
18990 //}
18991
18992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(version < 0x174)
18993 {
18994 tiles_used=TILES_PER_PAGE*4;
18995 } //no expanded tile space
18996
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 else if(version < 0x191)
18997 {
18998 2 tiles_used=OLDMAXTILES;
18999 2 }
19000 else
19001 {
19002 //finally... section data
19003
3/4
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
102 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19004 {
19005
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetl(&tiles_used,f,true))
19006 {
19007 delete[] temp_tile;
19008 return qe_invalid;
19009 }
19010 23 }
19011 else
19012 {
19013
1/2
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
79 if(!p_igetw(&tiles_used,f,true))
19014 {
19015 delete[] temp_tile;
19016 return qe_invalid;
19017 }
19018 }
19019 }
19020
19021
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 tiles_used=zc_min(tiles_used, max_tiles);
19022
19023 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19024 //if ( version < 0x254 && build < 41 )
19025
3/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if ( version < 0x254 || (version == 0x254 && build < 41) )
19026 //if ( build < 41 )
19027 {
19028
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19029 81 }
19030 else //2.55
19031 {
19032
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19033 }
19034
19035 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19036
19037 //al_trace("tiles_used = %d\n", tiles_used);
19038
19039
2/2
✓ Branch 0 taken 2408582 times.
✓ Branch 1 taken 104 times.
2408686 for(int32_t i=0; i<tiles_used; ++i)
19040 {
19041 2408582 byte format=tf4Bit;
19042 2408582 memset(temp_tile, 0, tilesize(tf32Bit));
19043
19044
3/6
✓ Branch 0 taken 169118 times.
✓ Branch 1 taken 2239464 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 169118 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2408582 if((version>0x211)||((version==0x211)&&(build>4)))
19045 {
19046
1/2
✓ Branch 0 taken 2239464 times.
✗ Branch 1 not taken.
2239464 if(!p_getc(&format,f,true))
19047 {
19048 delete[] temp_tile;
19049 return qe_invalid;
19050 }
19051 2239464 }
19052
4/4
✓ Branch 0 taken 557954 times.
✓ Branch 1 taken 1850628 times.
✓ Branch 2 taken 276608 times.
✓ Branch 3 taken 281346 times.
2408582 if(section_version > 2 && !format)
19053 {
19054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 281346 times.
281346 if(keepdata)
19055 {
19056 281346 reset_tile(buf,start_tile+i,tf4Bit);
19057 281346 }
19058 281346 continue;
19059 }
19060
19061
1/2
✓ Branch 0 taken 2127236 times.
✗ Branch 1 not taken.
2127236 if(!pfread(temp_tile,tilesize(format),f,true))
19062 {
19063 delete[] temp_tile;
19064 return qe_invalid;
19065 }
19066
19067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2127236 times.
2127236 if(keepdata==true)
19068 {
19069 2127236 buf[start_tile+i].format=format;
19070
19071
1/2
✓ Branch 0 taken 2127236 times.
✗ Branch 1 not taken.
2127236 if(buf[start_tile+i].data)
19072 {
19073 2127236 free(buf[start_tile+i].data);
19074 2127236 buf[start_tile+i].data=NULL;
19075 2127236 }
19076
19077 2127236 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19078 2127236 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19079 2127236 }
19080 2127236 }
19081 }
19082
19083
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19084 {
19085 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19086
2/2
✓ Branch 0 taken 12067380 times.
✓ Branch 1 taken 81 times.
12067461 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19087 {
19088
19089 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19090 12067380 reset_tile(buf,q,tf4Bit);
19091
19092
19093 /*
19094
19095 byte tempbyte;
19096 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19097 {
19098 tempbyte=buf[ZC250MAXTILES-1].data[i];
19099 buf[q].data[i] = tempbyte;
19100 }
19101 //int32_t temp = tempbyte=buf[130].data[i];
19102 //buf[q].data = buf[ZC250MAXTILES-1].data;
19103 */
19104 //reset_tile(buf,q,tf4Bit);
19105 12067380 }
19106
19107 81 }
19108
19109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
19110 {
19111
4/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23 times.
104 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19112 {
19113
2/2
✓ Branch 0 taken 3875580 times.
✓ Branch 1 taken 81 times.
3875661 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19114 {
19115 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19116 3875580 reset_tile(buf,i,tf4Bit);
19117 3875580 }
19118 81 }
19119 else
19120 {
19121
2/2
✓ Branch 0 taken 3956458 times.
✓ Branch 1 taken 23 times.
3956481 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19122 {
19123 //al_trace("Resetting tiles for build 41+\n");
19124 3956458 reset_tile(buf,i,tf4Bit);
19125 3956458 }
19126 }
19127
19128
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19129 {
19130
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 if(get_bit(quest_rules,qr_BSZELDA)) //
19131 {
19132 byte tempbyte;
19133 int32_t floattile=wpnsbuf[iwSwim].tile;
19134
19135 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19136 {
19137 tempbyte=buf[23].data[i];
19138 buf[23].data[i]=buf[24].data[i];
19139 buf[24].data[i]=buf[25].data[i];
19140 buf[25].data[i]=buf[26].data[i];
19141 buf[26].data[i]=tempbyte;
19142 }
19143 //swim tiles are out of order, too, but nobody cared? -Z
19144 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19145 {
19146 tempbyte=buf[floattile+11].data[i];
19147 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19148 buf[floattile+12].data[i]=tempbyte;
19149 }
19150 }
19151 2 }
19152
19153
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19154 {
19155
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 if(!get_bit(quest_rules,qr_NEWENEMYTILES))
19156 {
19157 byte tempbyte;
19158
19159
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 2 times.
258 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19160 {
19161 256 tempbyte=buf[130].data[i];
19162 256 buf[130].data[i]=buf[132].data[i];
19163 256 buf[132].data[i]=tempbyte;
19164
19165 256 tempbyte=buf[131].data[i];
19166 256 buf[131].data[i]=buf[133].data[i];
19167 256 buf[133].data[i]=tempbyte;
19168 256 }
19169 2 }
19170 7 }
19171
19172 104 al_trace("Registering blank tiles\n");
19173 104 register_blank_tiles();
19174 104 }
19175
19176 //memset(temp_tile, 0, tilesize(tf32Bit));
19177
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 delete[] temp_tile;
19178 104 temp_tile=NULL;
19179 104 return 0;
19180 104 }
19181
19182 104 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/, bool keepdata)
19183 {
19184 104 byte *mf=midi_flags;
19185 int32_t dummy;
19186 word dummy2;
19187 // zcmidi_ temp_midi;
19188 int32_t tunes_to_read;
19189 104 int32_t tune_count=0;
19190 104 word section_version=0;
19191 104 zctune temp;
19192
19193
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version < 0x193)
19194 {
19195 // mf=Header->data_flags+ZQ_MIDIS2;
19196
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19197 {
19198 2 tunes_to_read=MAXCUSTOMMIDIS192b177;
19199 2 }
19200 else
19201 {
19202 tunes_to_read=MAXCUSTOMTUNES;
19203 }
19204 2 }
19205 else
19206 {
19207 //section version info
19208
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&section_version,f,true))
19209 {
19210 return qe_invalid;
19211 }
19212
19213 102 FFCore.quest_format[vMIDIs] = section_version;
19214
19215 //al_trace("Tunes version %d\n", section_version);
19216
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy2,f,true))
19217 {
19218 return qe_invalid;
19219 }
19220
19221 //section size
19222
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
19223 {
19224 return qe_invalid;
19225 }
19226
19227 //finally... section data
19228
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!pfread(midi_flags,sizeof(midi_flags),f,true))
19229 {
19230 return qe_invalid;
19231 }
19232
19233 102 tunes_to_read=MAXCUSTOMTUNES;
19234 }
19235
19236
2/2
✓ Branch 0 taken 26208 times.
✓ Branch 1 taken 104 times.
26312 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19237 {
19238
2/2
✓ Branch 0 taken 24430 times.
✓ Branch 1 taken 1778 times.
26208 if(get_bit(mf, i))
19239 {
19240 1778 ++tune_count;
19241 1778 }
19242 26208 }
19243
19244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
19245 {
19246 104 reset_tunes(tunes); //reset_midis(midis);
19247 104 }
19248
19249
2/2
✓ Branch 0 taken 25768 times.
✓ Branch 1 taken 104 times.
25872 for(int32_t i=0; i<tunes_to_read; i++)
19250 {
19251 25768 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19252
19253
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25768 times.
25768 if(keepdata==true)
19254 {
19255 25768 tunes[i].reset(); // reset_midi(midis+i);
19256 25768 }
19257
19258
2/2
✓ Branch 0 taken 23990 times.
✓ Branch 1 taken 1778 times.
25768 if(get_bit(mf,i))
19259 {
19260
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 1531 times.
1778 if(section_version < 4)
19261 {
19262
1/2
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
247 if(!pfread(&temp.title,sizeof(char)*20,f,true))
19263 {
19264 return qe_invalid;
19265 }
19266 247 }
19267 else
19268 {
19269
1/2
✓ Branch 0 taken 1531 times.
✗ Branch 1 not taken.
1531 if(!pfread(&temp.title,sizeof(temp.title),f,true))
19270 {
19271 return qe_invalid;
19272 }
19273 }
19274
19275
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!p_igetl(&temp.start,f,true))
19276 {
19277 return qe_invalid;
19278 }
19279
19280
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!p_igetl(&temp.loop_start,f,true))
19281 {
19282 return qe_invalid;
19283 }
19284
19285
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!p_igetl(&temp.loop_end,f,true))
19286 {
19287 return qe_invalid;
19288 }
19289
19290
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!p_igetw(&temp.loop,f,true))
19291 {
19292 return qe_invalid;
19293 }
19294
19295
1/2
✓ Branch 0 taken 1778 times.
✗ Branch 1 not taken.
1778 if(!p_igetw(&temp.volume,f,true))
19296 {
19297 return qe_invalid;
19298 }
19299
19300
2/2
✓ Branch 0 taken 1750 times.
✓ Branch 1 taken 28 times.
1778 if(Header->zelda_version < 0x193)
19301 {
19302
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_igetl(&dummy,f,true))
19303 {
19304 return qe_invalid;
19305 }
19306 28 }
19307
19308
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 1531 times.
1778 if(section_version >= 3)
19309 {
19310
1/2
✓ Branch 0 taken 1531 times.
✗ Branch 1 not taken.
1531 if(!pfread(&temp.flags,sizeof(temp.flags),f,true))
19311 {
19312 return qe_invalid;
19313 }
19314 1531 }
19315
19316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1778 times.
1778 if(keepdata==true)
19317 {
19318 1778 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19319 1778 }
19320
19321
2/2
✓ Branch 0 taken 247 times.
✓ Branch 1 taken 1531 times.
1778 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19322 {
19323 // old format - a midi is a midi
19324
2/4
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 247 times.
✗ Branch 3 not taken.
247 if(((keepdata==true?tunes[i].data:temp.data)=read_midi(f, true))==NULL)
19325 {
19326 return qe_invalid;
19327 }
19328
19329 //yes you can do this. Isn't the ? operator awesome? :)
19330
1/2
✓ Branch 0 taken 247 times.
✗ Branch 1 not taken.
247 (keepdata ? tunes[i] : temp).format = MFORMAT_MIDI;
19331 247 }
19332 else
19333 {
19334 // 'midi' could be midi or nes, gb, ... music
19335
2/4
✓ Branch 0 taken 1531 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1531 times.
✗ Branch 3 not taken.
1531 if(!pfread(&(keepdata ? tunes[i] : temp).format,sizeof((keepdata ? tunes[i] : temp).format),f,true))
19336 {
19337 return qe_invalid;
19338 }
19339
19340
1/2
✓ Branch 0 taken 1531 times.
✗ Branch 1 not taken.
1531 zctune *ptr = (keepdata==true)?&(tunes[i]):&temp;
19341
19342
1/2
✓ Branch 0 taken 1531 times.
✗ Branch 1 not taken.
1531 switch(temp.format)
19343 {
19344 case MFORMAT_MIDI:
19345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1531 times.
1531 if((ptr->data=read_midi(f, true))==NULL)
19346 {
19347 return qe_invalid;
19348 }
19349
19350 1531 break;
19351
19352 default:
19353 return qe_invalid;
19354 break;
19355 }
19356 }
19357 1778 }
19358 25768 }
19359
19360 104 return 0;
19361 104 }
19362
19363 104 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header, bool keepdata)
19364 {
19365 int32_t dummy;
19366 ZCHEATS tempzcheats;
19367 104 char temp_use_cheats=1;
19368 104 memset(&tempzcheats, 0, sizeof(tempzcheats));
19369 104 word s_version = 0;
19370
19371
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
104 if(Header->zelda_version > 0x192)
19372 {
19373 //section version info
19374
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&s_version,f,true))
19375 {
19376 return qe_invalid;
19377 }
19378
19379 102 FFCore.quest_format[vCheats] = s_version;
19380 //al_trace("Cheats version %d\n", dummy);
19381
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetw(&dummy,f,true))
19382 {
19383 return qe_invalid;
19384 }
19385
19386 //section size
19387
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_igetl(&dummy,f,true))
19388 {
19389 return qe_invalid;
19390 }
19391
19392 //finally... section data
19393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 if(!p_getc(&temp_use_cheats,f,true))
19394 {
19395 return qe_invalid;
19396 }
19397 102 }
19398
19399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(Header->data_flags[ZQ_CHEATS2])
19400 {
19401
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!p_igetl(&tempzcheats.flags,f,true))
19402 {
19403 return qe_invalid;
19404 }
19405
19406
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes), f,true))
19407 {
19408 return qe_invalid;
19409 }
19410 104 }
19411
19412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(keepdata==true)
19413 {
19414 104 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19415 104 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19416 104 }
19417
19418 104 return 0;
19419 104 }
19420
19421 272 int32_t readinitdata(PACKFILE *f, zquestheader *Header, bool keepdata)
19422 {
19423 int32_t dummy;
19424 272 word s_version=0, s_cversion=0;
19425 byte padding;
19426 word tempw;
19427
19428 272 zinitdata temp_zinit;
19429
19430 // Legacy item properties (now integrated into itemdata)
19431 byte sword_hearts[4];
19432 byte beam_hearts[4];
19433 272 byte beam_percent=0;
19434 word beam_power[4];
19435 272 byte hookshot_length=99;
19436 272 byte hookshot_links=100;
19437 272 byte longshot_length=99;
19438 272 byte longshot_links=100;
19439 272 byte moving_fairy_hearts=3;
19440 272 byte moving_fairy_heart_percent=0;
19441 272 byte stationary_fairy_hearts=3;
19442 272 byte stationary_fairy_heart_percent=0;
19443 272 byte moving_fairy_magic=0;
19444 272 byte moving_fairy_magic_percent=0;
19445 272 byte stationary_fairy_magic=0;
19446 272 byte stationary_fairy_magic_percent=0;
19447 272 byte blue_potion_hearts=100;
19448 272 byte blue_potion_heart_percent=1;
19449 272 byte red_potion_hearts=100;
19450 272 byte red_potion_heart_percent=1;
19451 272 byte blue_potion_magic=100;
19452 272 byte blue_potion_magic_percent=1;
19453 272 byte red_potion_magic=100;
19454 272 byte red_potion_magic_percent=1;
19455
19456
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 168 times.
272 temp_zinit.subscreen_style=get_bit(quest_rules,qr_COOLSCROLL)?1:0;
19457
19458
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(Header->zelda_version > 0x192)
19459 {
19460 //section version info
19461
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&s_version,f,true))
19462 {
19463 return qe_invalid;
19464 }
19465
19466 102 FFCore.quest_format[vInitData] = s_version;
19467
19468 //al_trace("Init data version %d\n", s_version);
19469
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&s_cversion,f,true))
19470 {
19471 return qe_invalid;
19472 }
19473
19474 //section size
19475
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetl(&dummy,f,true))
19476 {
19477 return qe_invalid;
19478 }
19479 102 }
19480
19481 /* HIGHLY UNORTHODOX UPDATING THING, by L
19482 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19483 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19484 * changing from 13 to 14.
19485 */
19486
3/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✓ Branch 3 taken 7 times.
104 if(keepdata && s_version < 14)
19487 7 fixpolsvoice=true;
19488
19489 /* End highly unorthodox updating thing */
19490
19491
5/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 73 times.
✓ Branch 5 taken 24 times.
104 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19492 24 temp_zinit.jump_hero_layer_threshold=0;
19493
19494
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
104 if(s_version >= 10)
19495 {
19496 char temp;
19497
19498 //new-style items
19499
2/2
✓ Branch 0 taken 24832 times.
✓ Branch 1 taken 97 times.
24929 for(int32_t j=0; j<256; j++)
19500 {
19501
2/4
✓ Branch 0 taken 24832 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 24832 times.
24832 if(!p_getc(&temp,f,true))
19502 return qe_invalid;
19503
19504 24832 temp_zinit.items[j] = (temp != 0);
19505 24832 }
19506 97 }
19507
19508
5/6
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 66 times.
✓ Branch 5 taken 66 times.
104 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19509 {
19510 char temp;
19511
19512 //finally... section data
19513
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 66 times.
168 if((Header->zelda_version > 0x192)||
19514 //new only
19515 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19516 {
19517 //OLD-style items... sigh
19518
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version < 10)
19519 {
19520
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19521 {
19522 return qe_invalid;
19523 }
19524
19525 5 temp_zinit.items[iRaft]=(temp != 0);
19526
19527
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19528 {
19529 return qe_invalid;
19530 }
19531
19532 5 temp_zinit.items[iLadder]=(temp != 0);
19533
19534
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19535 {
19536 return qe_invalid;
19537 }
19538
19539 5 temp_zinit.items[iBook]=(temp != 0);
19540
19541
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19542 {
19543 return qe_invalid;
19544 }
19545
19546 5 temp_zinit.items[iMKey]=(temp!=0);
19547
19548
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19549 {
19550 return qe_invalid;
19551 }
19552
19553 5 temp_zinit.items[iFlippers]=(temp != 0);
19554
19555
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19556 {
19557 return qe_invalid;
19558 }
19559
19560 5 temp_zinit.items[iBoots]=(temp!=0);
19561 5 }
19562 102 }
19563
19564
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 149 times.
168 if(s_version < 10)
19565 {
19566 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19567
19568
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempring,f,true))
19569 {
19570 return qe_invalid;
19571 }
19572
19573
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempsword,f,true))
19574 {
19575 return qe_invalid;
19576 }
19577
19578
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempshield,f,true))
19579 {
19580 return qe_invalid;
19581 }
19582
19583
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwallet,f,true))
19584 {
19585 return qe_invalid;
19586 }
19587
19588
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbracelet,f,true))
19589 {
19590 return qe_invalid;
19591 }
19592
19593
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempamulet,f,true))
19594 {
19595 return qe_invalid;
19596 }
19597
19598
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbow,f,true))
19599 {
19600 return qe_invalid;
19601 }
19602
19603 //old only
19604
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19605 {
19606 tempring=(tempring)?(1<<(tempring-1)):0;
19607 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19608 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19609 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19610 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19611 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19612 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19613 }
19614
19615 //rings start at level 2... wtf
19616 //account for this -DD
19617 5 tempring <<= 1;
19618
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19619
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19620
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19621
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19622 //bracelet ALSO starts at level 2 :-( -DD
19623 5 tempbracelet<<=1;
19624
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19625
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19626
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19627
19628 //new only
19629
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
19630 {
19631 for(int32_t q=0; q<32; q++)
19632 {
19633 if(!p_getc(&padding,f,true))
19634 {
19635 return qe_invalid;
19636 }
19637 }
19638 }
19639
19640 char tempcandle, tempboomerang, temparrow, tempwhistle;
19641
19642
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempcandle,f,true))
19643 {
19644 return qe_invalid;
19645 }
19646
19647
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempboomerang,f,true))
19648 {
19649 return qe_invalid;
19650 }
19651
19652
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temparrow,f,true))
19653 {
19654 return qe_invalid;
19655 }
19656
19657
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19658 {
19659 return qe_invalid;
19660 }
19661
19662
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19663
19664
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempwhistle,f,true))
19665 {
19666 return qe_invalid;
19667 }
19668
19669 //old only
19670
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version == 0x192)&&(Header->build<174))
19671 {
19672 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19673 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19674 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19675 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19676 }
19677
19678
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19679
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19680
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19681
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19682 //What about the potion...?
19683
19684 5 }
19685
19686
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 75 times.
154 if(s_version < 29)
19687 {
19688 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19689 //to jab out my eye...
19690
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
79 if(!p_getc(&padding,f,true))
19691 return qe_invalid;
19692 79 temp_zinit.bombs = padding;
19693
19694
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
79 if(!p_getc(&padding,f,true))
19695 return qe_invalid;
19696 79 temp_zinit.super_bombs = padding;
19697 79 }
19698
19699 //Back to more OLD item code
19700
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
154 if(s_version < 10)
19701 {
19702
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5 if((Header->zelda_version > 0x192)||
19703 //new only
19704 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19705 {
19706
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19707 {
19708 return qe_invalid;
19709 }
19710
19711
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19712
19713
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19714 {
19715 return qe_invalid;
19716 }
19717
19718
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19719
19720
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19721 {
19722 return qe_invalid;
19723 }
19724
19725
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19726
19727
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19728 {
19729 return qe_invalid;
19730 }
19731
19732
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19733
19734
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19735 {
19736 return qe_invalid;
19737 }
19738
19739
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19740
19741
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19742 {
19743 return qe_invalid;
19744 }
19745
19746
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19747
19748
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19749 {
19750 return qe_invalid;
19751 }
19752
19753
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19754
19755
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19756 {
19757 return qe_invalid;
19758 }
19759
19760
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19761
19762
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19763 {
19764 return qe_invalid;
19765 }
19766
19767
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19768
19769
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temp,f,true))
19770 {
19771 return qe_invalid;
19772 }
19773
19774
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 if(Header->zelda_version == 0x192)
19775 {
19776 for(int32_t q=0; q<32; q++)
19777 {
19778 if(!p_getc(&padding,f,true))
19779 {
19780 return qe_invalid;
19781 }
19782 }
19783 }
19784 5 }
19785 5 }
19786
19787 //old only
19788
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
10 if((Header->zelda_version == 0x192)&&(Header->build<174))
19789 {
19790 byte equipment, items; //bit flags
19791
19792 if(!p_getc(&equipment,f,true))
19793 {
19794 return qe_invalid;
19795 }
19796
19797 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19798 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19799 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19800 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19801 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19802 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19803
19804
19805 if(!p_getc(&items,f,true))
19806 {
19807 return qe_invalid;
19808 }
19809
19810 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19811 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19812 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19813 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19814 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19815 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19816 }
19817
19818 if(!p_getc(&temp_zinit.hc,f,true))
19819 {
19820 return qe_invalid;
19821 }
19822
19823
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version < 14)
19824 {
19825 byte temphp;
19826
19827
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
19828 {
19829 return qe_invalid;
19830 }
19831
19832 5 temp_zinit.start_heart=temphp;
19833
19834
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&temphp,f,true))
19835 {
19836 return qe_invalid;
19837 }
19838
19839 5 temp_zinit.cont_heart=temphp;
19840 5 }
19841 else
19842 {
19843
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.start_heart,f,true))
19844 {
19845 return qe_invalid;
19846 }
19847
19848
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.cont_heart,f,true))
19849 {
19850 return qe_invalid;
19851 }
19852 }
19853
19854
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.hcp,f,true))
19855 {
19856 return qe_invalid;
19857 }
19858
19859
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version >= 14)
19860 {
19861
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.hcp_per_hc,f,true))
19862 {
19863 return qe_invalid;
19864 }
19865
19866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version<16) // July 2007
19867 {
19868 if(get_bit(quest_rules,qr_BRANGPICKUP+1))
19869 temp_zinit.hcp_per_hc = 0xFF;
19870
19871 //Dispose of legacy rule
19872 set_bit(quest_rules,qr_BRANGPICKUP+1, 0);
19873 }
19874 97 }
19875
19876
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 23 times.
102 if(s_version < 29)
19877 {
19878
2/4
✓ Branch 0 taken 79 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
79 if(!p_getc(&padding,f,true))
19879 return qe_invalid;
19880 79 temp_zinit.max_bombs = padding;
19881 79 }
19882
19883
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.keys,f,true))
19884 {
19885 return qe_invalid;
19886 }
19887
19888
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_igetw(&temp_zinit.rupies,f,true))
19889 {
19890 return qe_invalid;
19891 }
19892
19893
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.triforce,f,true))
19894 {
19895 return qe_invalid;
19896 }
19897
19898
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19899 {
19900
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 97 times.
6305 for(int32_t i=0; i<64; i++)
19901 {
19902
2/4
✓ Branch 0 taken 6208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6208 times.
6208 if(!p_getc(&temp_zinit.map[i],f,true))
19903 {
19904 return qe_invalid;
19905 }
19906 6208 }
19907
19908
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 97 times.
6305 for(int32_t i=0; i<64; i++)
19909 {
19910
2/4
✓ Branch 0 taken 6208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6208 times.
6208 if(!p_getc(&temp_zinit.compass[i],f,true))
19911 {
19912 return qe_invalid;
19913 }
19914 6208 }
19915 97 }
19916 else
19917 {
19918
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
19919 {
19920
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.map[i],f,true))
19921 {
19922 return qe_invalid;
19923 }
19924 160 }
19925
19926
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
19927 {
19928
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 160 times.
160 if(!p_getc(&temp_zinit.compass[i],f,true))
19929 {
19930 return qe_invalid;
19931 }
19932 160 }
19933 }
19934
19935
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if((Header->zelda_version > 0x192)||
19936 //new only
19937 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19938 {
19939
3/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19940 {
19941
2/2
✓ Branch 0 taken 6208 times.
✓ Branch 1 taken 97 times.
6305 for(int32_t i=0; i<64; i++)
19942 {
19943
2/4
✓ Branch 0 taken 6208 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6208 times.
6208 if(!p_getc(&temp_zinit.boss_key[i],f,true))
19944 {
19945 return qe_invalid;
19946 }
19947 6208 }
19948 97 }
19949 else
19950 {
19951
2/2
✓ Branch 0 taken 160 times.
✓ Branch 1 taken 5 times.
165 for(int32_t i=0; i<32; i++)
19952 {
19953
2/4
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
160 if(!p_getc(&temp_zinit.boss_key[i],f,true))
19954 {
19955 return qe_invalid;
19956 }
19957 160 }
19958 }
19959 102 }
19960
19961
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 1632 times.
1734 for(int32_t i=0; i<16; i++)
19962 {
19963
2/4
✓ Branch 0 taken 1632 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1632 times.
1632 if(!p_getc(&temp_zinit.misc[i],f,true))
19964 {
19965 return qe_invalid;
19966 }
19967 1632 }
19968
19969
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 5 times.
122 if(s_version < 15) for(int32_t i=0; i<4; i++)
19970 {
19971
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&sword_hearts[i],f,true))
19972 {
19973 return qe_invalid;
19974 }
19975 25 }
19976
19977
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.last_map,f,true))
19978 {
19979 return qe_invalid;
19980 }
19981
19982
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.last_screen,f,true))
19983 {
19984 return qe_invalid;
19985 }
19986
19987
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version < 14)
19988 {
19989 byte tempmp;
19990
19991
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
19992 {
19993 return qe_invalid;
19994 }
19995
19996 5 temp_zinit.max_magic=tempmp;
19997
19998
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempmp,f,true))
19999 {
20000 return qe_invalid;
20001 }
20002
20003 5 temp_zinit.magic=tempmp;
20004 5 }
20005 else
20006 {
20007
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.max_magic,f,true))
20008 {
20009 return qe_invalid;
20010 }
20011
20012
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.magic,f,true))
20013 {
20014 return qe_invalid;
20015 }
20016 }
20017
20018
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version < 15)
20019 {
20020
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version < 12)
20021 {
20022 5 temp_zinit.max_magic*=32;
20023 5 temp_zinit.magic*=32;
20024 5 }
20025
20026
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20027 {
20028
2/4
✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
20 if(!p_getc(&beam_hearts[i],f,true))
20029 {
20030 return qe_invalid;
20031 }
20032 20 }
20033
20034
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&beam_percent,f,true))
20035 {
20036 return qe_invalid;
20037 }
20038 5 }
20039 else
20040 {
20041
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.bomb_ratio,f,true))
20042 {
20043 return qe_invalid;
20044 }
20045 }
20046
20047
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version < 15)
20048 {
20049 byte tempbp;
20050
20051
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 20 times.
25 for(int32_t i=0; i<4; i++)
20052 {
20053
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
20 if(!(s_version < 14 ? p_getc(&tempbp,f,true) : p_igetw(&tempbp,f,true)))
20054 {
20055 return qe_invalid;
20056 }
20057
20058 20 beam_power[i]=tempbp;
20059 20 }
20060
20061
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&hookshot_links,f,true))
20062 {
20063 return qe_invalid;
20064 }
20065
20066
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(s_version>6)
20067 {
20068 if(!p_getc(&hookshot_length,f,true))
20069 {
20070 return qe_invalid;
20071 }
20072
20073 if(!p_getc(&longshot_links,f,true))
20074 {
20075 return qe_invalid;
20076 }
20077
20078 if(!p_getc(&longshot_length,f,true))
20079 {
20080 return qe_invalid;
20081 }
20082 }
20083 5 }
20084
20085
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.msg_more_x,f,true))
20086 {
20087 return qe_invalid;
20088 }
20089
20090
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.msg_more_y,f,true))
20091 {
20092 return qe_invalid;
20093 }
20094
20095
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.subscreen,f,true))
20096 {
20097 return qe_invalid;
20098 }
20099
20100 //old only
20101
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if((Header->zelda_version == 0x192)&&(Header->build<174))
20102 {
20103 for(int32_t i=0; i<32; i++)
20104 {
20105 if(!p_getc(&temp_zinit.boss_key[i],f,true))
20106 {
20107 return qe_invalid;
20108 }
20109 }
20110 }
20111
20112
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
102 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20113 {
20114
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version <= 10)
20115 {
20116 byte tempbyte;
20117
20118
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if(!p_getc(&tempbyte,f,true))
20119 {
20120 return qe_invalid;
20121 }
20122
20123 5 temp_zinit.start_dmap = (word)tempbyte;
20124 5 }
20125 else
20126 {
20127
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.start_dmap,f,true))
20128 {
20129 return qe_invalid;
20130 }
20131 }
20132
20133
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102 times.
✗ Branch 3 not taken.
102 if(!p_getc(&temp_zinit.heroAnimationStyle,f,true))
20134 {
20135 return qe_invalid;
20136 }
20137 102 }
20138
20139
4/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 74 times.
✓ Branch 3 taken 23 times.
102 if(s_version>1 && s_version < 29)
20140 {
20141
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20142 return qe_invalid;
20143 74 temp_zinit.arrows = padding;
20144
20145
2/4
✓ Branch 0 taken 74 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 74 times.
✗ Branch 3 not taken.
74 if(!p_getc(&padding,f,true))
20146 return qe_invalid;
20147 74 temp_zinit.max_arrows = padding;
20148 74 }
20149
20150
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 97 times.
102 if(s_version>2)
20151 {
20152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(s_version <= 10)
20153 {
20154 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20155 {
20156 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20157 {
20158 return qe_invalid;
20159 }
20160 }
20161 }
20162 else
20163 {
20164
2/2
✓ Branch 0 taken 49664 times.
✓ Branch 1 taken 97 times.
49761 for(int32_t i=0; i<MAXLEVELS; i++)
20165 {
20166
2/4
✓ Branch 0 taken 49664 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49664 times.
✗ Branch 3 not taken.
49664 if(!p_getc(&(temp_zinit.level_keys[i]),f,true))
20167 {
20168 return qe_invalid;
20169 }
20170 49664 }
20171 }
20172 97 }
20173
20174
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>3)
20175 {
20176
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_grid_x,f,true))
20177 {
20178 return qe_invalid;
20179 }
20180
20181
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_grid_y,f,true))
20182 {
20183 return qe_invalid;
20184 }
20185
20186
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_grid_xofs,f,true))
20187 {
20188 return qe_invalid;
20189 }
20190
20191
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_grid_yofs,f,true))
20192 {
20193 return qe_invalid;
20194 }
20195
20196
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_grid_color,f,true))
20197 {
20198 return qe_invalid;
20199 }
20200
20201
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f,true))
20202 {
20203 return qe_invalid;
20204 }
20205
20206
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f,true))
20207 {
20208 return qe_invalid;
20209 }
20210
20211
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.ss_flags,f,true))
20212 {
20213 return qe_invalid;
20214 }
20215
20216
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20217
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20218 97 }
20219
20220
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
102 if(s_version>4 && s_version<15)
20221 {
20222 if(!p_getc(&moving_fairy_hearts,f,true))
20223 {
20224 return qe_invalid;
20225 }
20226
20227 if(!p_getc(&moving_fairy_heart_percent,f,true))
20228 {
20229 return qe_invalid;
20230 }
20231 }
20232
20233
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
102 if(s_version>5 && s_version < 10)
20234 {
20235 if(!p_getc(&temp,f,true))
20236 {
20237 return qe_invalid;
20238 }
20239
20240 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20241 }
20242
20243
3/4
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
102 if(s_version>6 && s_version<15)
20244 {
20245 if(!p_getc(&stationary_fairy_hearts,f,true))
20246 {
20247 return qe_invalid;
20248 }
20249
20250 if(!p_getc(&stationary_fairy_heart_percent,f,true))
20251 {
20252 return qe_invalid;
20253 }
20254
20255 if(!p_getc(&moving_fairy_magic,f,true))
20256 {
20257 return qe_invalid;
20258 }
20259
20260 if(!p_getc(&moving_fairy_magic_percent,f,true))
20261 {
20262 return qe_invalid;
20263 }
20264
20265 if(!p_getc(&stationary_fairy_magic,f,true))
20266 {
20267 return qe_invalid;
20268 }
20269
20270 if(!p_getc(&stationary_fairy_magic_percent,f,true))
20271 {
20272 return qe_invalid;
20273 }
20274
20275 if(!p_getc(&blue_potion_hearts,f,true))
20276 {
20277 return qe_invalid;
20278 }
20279
20280 if(!p_getc(&blue_potion_heart_percent,f,true))
20281 {
20282 return qe_invalid;
20283 }
20284
20285 if(!p_getc(&red_potion_hearts,f,true))
20286 {
20287 return qe_invalid;
20288 }
20289
20290 if(!p_getc(&red_potion_heart_percent,f,true))
20291 {
20292 return qe_invalid;
20293 }
20294
20295 if(!p_getc(&blue_potion_magic,f,true))
20296 {
20297 return qe_invalid;
20298 }
20299
20300 if(!p_getc(&blue_potion_magic_percent,f,true))
20301 {
20302 return qe_invalid;
20303 }
20304
20305 if(!p_getc(&red_potion_magic,f,true))
20306 {
20307 return qe_invalid;
20308 }
20309
20310 if(!p_getc(&red_potion_magic_percent,f,true))
20311 {
20312 return qe_invalid;
20313 }
20314 }
20315
20316
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>6)
20317 {
20318
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.subscreen_style,f,true))
20319 {
20320 return qe_invalid;
20321 }
20322 97 }
20323
20324
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>7)
20325 {
20326
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.usecustomsfx,f,true))
20327 {
20328 return qe_invalid;
20329 }
20330 97 }
20331
20332
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>8)
20333 {
20334
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.max_rupees,f,true))
20335 {
20336 return qe_invalid;
20337 }
20338
20339
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.max_keys,f,true))
20340 {
20341 return qe_invalid;
20342 }
20343 97 }
20344
20345
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>16)
20346 {
20347
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.gravity,f,true))
20348 {
20349 return qe_invalid;
20350 }
20351
20352
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_igetw(&temp_zinit.terminalv,f,true))
20353 {
20354 return qe_invalid;
20355 }
20356
20357
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.msg_speed,f,true))
20358 {
20359 return qe_invalid;
20360 }
20361
20362
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.transition_type,f,true))
20363 {
20364 return qe_invalid;
20365 }
20366
20367
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f,true))
20368 {
20369 return qe_invalid;
20370 }
20371 97 }
20372
4/8
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5 times.
5 else if(replay_is_replaying() && replay_get_version() < 13)
20373 5 temp_zinit.msg_speed = 0;
20374
20375
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 5 times.
102 if(s_version>17)
20376 {
20377
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 97 times.
✗ Branch 3 not taken.
97 if(!p_getc(&temp_zinit.msg_more_is_offset,f,true))
20378 {
20379 return qe_invalid;
20380 }
20381 97 }
20382
20383 //expaned init data for larger values in 2.55
20384
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20385 {
20386
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.bombs,f,true))
20387 {
20388 return qe_invalid;
20389 }
20390
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.super_bombs,f,true))
20391 {
20392 return qe_invalid;
20393 }
20394
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_bombs,f,true))
20395 {
20396 return qe_invalid;
20397 }
20398
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_sbombs,f,true))
20399 {
20400 return qe_invalid;
20401 }
20402
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.arrows,f,true))
20403 {
20404 return qe_invalid;
20405 }
20406
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.max_arrows,f,true))
20407 {
20408 return qe_invalid;
20409 }
20410
20411 23 }
20412
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if ( s_version >= 20 )
20413 {
20414
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroStep,f,true))
20415 {
20416 return qe_invalid;
20417 }
20418 23 }
20419 else
20420 {
20421 79 temp_zinit.heroStep = 150; //1.5 pixels per frame
20422 }
20423
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 79 times.
102 if ( s_version >= 21 )
20424 {
20425
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.subscrSpeed,f,true))
20426 {
20427 return qe_invalid;
20428 }
20429 23 }
20430 else
20431 {
20432 79 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20433 }
20434 //old only
20435
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
102 if((Header->zelda_version == 0x192)&&(Header->build<174))
20436 {
20437 byte items2;
20438
20439 if(!p_getc(&items2,f,true))
20440 {
20441 return qe_invalid;
20442 }
20443
20444 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20445 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20446 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20447 }
20448
20449
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(Header->zelda_version < 0x193)
20450 {
20451 for(int32_t q=0; q<96; q++)
20452 {
20453 if(!p_getc(&padding,f,true))
20454 {
20455 return qe_invalid;
20456 }
20457 }
20458
20459 //new only
20460 if((Header->zelda_version == 0x192)&&(Header->build>173))
20461 {
20462 if(!p_getc(&padding,f,true))
20463 {
20464 return qe_invalid;
20465 }
20466
20467 if(!p_getc(&padding,f,true))
20468 {
20469 return qe_invalid;
20470 }
20471 }
20472 }
20473 102 }
20474
20475
3/6
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
170 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20476 {
20477 //temp_zinit.shield=i_smallshield;
20478
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 66 times.
73 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20479
20480
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(sshieldid != -1)
20481 7 temp_zinit.items[sshieldid] = true;
20482 7 }
20483
20484
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20485 {
20486 2 temp_zinit.hc=3;
20487 2 temp_zinit.start_heart=3;
20488 2 temp_zinit.cont_heart=3;
20489 2 temp_zinit.max_bombs=8;
20490 2 }
20491
20492
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20493 {
20494 2 sword_hearts[0]=0;
20495 2 sword_hearts[1]=5;
20496 2 sword_hearts[2]=12;
20497 2 sword_hearts[3]=21;
20498 2 }
20499
20500
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20501 {
20502 2 temp_zinit.last_map=0;
20503 2 temp_zinit.last_screen=0;
20504 2 }
20505
20506
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20507 {
20508 2 temp_zinit.max_magic=0;
20509 2 temp_zinit.magic=0;
20510
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20511 2 }
20512
20513
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20514 {
20515
20516
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t x=0; x<4; x++)
20517 {
20518 8 beam_hearts[x]=100;
20519 8 }
20520
20521
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t i=0; i<idBP_MAX; i++)
20522 {
20523
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
8 set_bit(&beam_percent,i,!get_bit(quest_rules,qr_LENSHINTS+i));
20524
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 set_bit(quest_rules,qr_LENSHINTS+i,0);
20525 8 }
20526
20527
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 8 times.
10 for(int32_t x=0; x<4; x++)
20528 {
20529
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 beam_power[x]=get_bit(quest_rules,qr_HIDECARRIEDITEMS)?50:100;
20530 8 }
20531
20532
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 set_bit(quest_rules,qr_HIDECARRIEDITEMS,0);
20533 2 hookshot_links=100;
20534 2 temp_zinit.msg_more_x=224;
20535 2 temp_zinit.msg_more_y=64;
20536 2 }
20537
20538 // Okay, let's put these legacy values into itemsbuf.
20539
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(s_version < 15)
20540
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 1792 times.
1799 for(int32_t i=0; i<MAXITEMS; i++)
20541 {
20542
11/11
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✓ Branch 5 taken 7 times.
✓ Branch 6 taken 7 times.
✓ Branch 7 taken 7 times.
✓ Branch 8 taken 1722 times.
✓ Branch 9 taken 7 times.
✓ Branch 10 taken 7 times.
1792 switch(i)
20543 {
20544 case iFairyStill:
20545 7 itemsbuf[i].misc1 = stationary_fairy_hearts;
20546 7 itemsbuf[i].misc2 = stationary_fairy_magic;
20547 7 itemsbuf[i].misc3 = 0;
20548 7 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20549 7 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20550 7 break;
20551
20552 case iFairyMoving:
20553 7 itemsbuf[i].misc1 = moving_fairy_hearts;
20554 7 itemsbuf[i].misc2 = moving_fairy_magic;
20555 7 itemsbuf[i].misc3 = 50;
20556 7 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20557 7 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20558 7 break;
20559
20560 case iRPotion:
20561 7 itemsbuf[i].misc1 = red_potion_hearts;
20562 7 itemsbuf[i].misc2 = red_potion_magic;
20563 7 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20564 7 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20565 7 break;
20566
20567 case iBPotion:
20568 7 itemsbuf[i].misc1 = blue_potion_hearts;
20569 7 itemsbuf[i].misc2 = blue_potion_magic;
20570 7 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20571 7 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20572 7 break;
20573
20574 case iSword:
20575 7 itemsbuf[i].pickup_hearts = sword_hearts[0];
20576 7 itemsbuf[i].misc1 = beam_hearts[0];
20577 7 itemsbuf[i].misc2 = beam_power[0];
20578 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20579
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20580 7 break;
20581
20582 case iWSword:
20583 7 itemsbuf[i].pickup_hearts = sword_hearts[1];
20584 7 itemsbuf[i].misc1 = beam_hearts[1];
20585 7 itemsbuf[i].misc2 = beam_power[1];
20586
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20587 7 break;
20588
20589 case iMSword:
20590 7 itemsbuf[i].pickup_hearts = sword_hearts[2];
20591 7 itemsbuf[i].misc1 = beam_hearts[2];
20592 7 itemsbuf[i].misc2 = beam_power[2];
20593
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20594 7 break;
20595
20596 case iXSword:
20597 7 itemsbuf[i].pickup_hearts = sword_hearts[3];
20598 7 itemsbuf[i].misc1 = beam_hearts[3];
20599 7 itemsbuf[i].misc2 = beam_power[3];
20600
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20601 7 break;
20602
20603 case iHookshot:
20604 7 itemsbuf[i].misc1 = hookshot_length;
20605 7 itemsbuf[i].misc2 = hookshot_links;
20606 7 break;
20607
20608 case iLongshot:
20609 7 itemsbuf[i].misc1 = longshot_length;
20610 7 itemsbuf[i].misc2 = longshot_links;
20611 7 break;
20612 }
20613 1799 }
20614
20615
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20616 {
20617 //was new subscreen rule
20618
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 temp_zinit.subscreen=get_bit(quest_rules,qr_FREEFORM)?1:0;
20619
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 set_bit(quest_rules,qr_FREEFORM,0);
20620 2 }
20621
20622
3/4
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20623 {
20624 2 temp_zinit.start_dmap=0;
20625 2 }
20626
20627
3/6
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20628 {
20629
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 temp_zinit.heroAnimationStyle=get_bit(quest_rules,qr_BSZELDA)?1:0;
20630 2 }
20631
20632
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
104 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20633 {
20634 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20635 temp_zinit.max_rupees=999;
20636 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20637 }
20638
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20639 {
20640 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20641 temp_zinit.max_bombs = 8;
20642 }
20643 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20644 //time to ensure that we port all new values properly:
20645
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 7 times.
104 if(Header->zelda_version < 0x250)
20646 {
20647
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20648 7 }
20649
20650
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 21)
20651 {
20652
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hp_per_heart,f,true))
20653 {
20654 return qe_invalid;
20655 }
20656
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.magic_per_block,f,true))
20657 {
20658 return qe_invalid;
20659 }
20660
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.hero_damage_multiplier,f,true))
20661 {
20662 return qe_invalid;
20663 }
20664
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.ene_damage_multiplier,f,true))
20665 {
20666 return qe_invalid;
20667 }
20668 23 }
20669 else
20670 {
20671 81 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20672 81 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20673 81 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20674 81 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20675 }
20676
20677
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 22)
20678 {
20679
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 23 times.
598 for(int32_t q = 0; q < 25; ++q)
20680 {
20681
2/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
575 if(!p_igetw(&temp_zinit.scrcnt[q],f,true))
20682 {
20683 return qe_invalid;
20684 }
20685 575 }
20686
2/2
✓ Branch 0 taken 575 times.
✓ Branch 1 taken 23 times.
598 for(int32_t q = 0; q < 25; ++q)
20687 {
20688
2/4
✓ Branch 0 taken 575 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 575 times.
575 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f,true))
20689 {
20690 return qe_invalid;
20691 }
20692 575 }
20693 23 }
20694 else
20695 {
20696
2/2
✓ Branch 0 taken 2025 times.
✓ Branch 1 taken 81 times.
2106 for(int32_t q = 0; q < 25; ++q)
20697 {
20698 2025 temp_zinit.scrcnt[q] = 0;
20699 2025 temp_zinit.scrmaxcnt[q] = 0;
20700 2025 }
20701 }
20702
20703
20704
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 23)
20705 {
20706
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_type,f,true))
20707 {
20708 return qe_invalid;
20709 }
20710
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_arg,f,true))
20711 {
20712 return qe_invalid;
20713 }
20714
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.dither_percent,f,true))
20715 {
20716 return qe_invalid;
20717 }
20718
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.def_lightrad,f,true))
20719 {
20720 return qe_invalid;
20721 }
20722
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.transdark_percent,f,true))
20723 {
20724 return qe_invalid;
20725 }
20726 23 }
20727 else
20728 {
20729 81 temp_zinit.dither_type = 0;
20730 81 temp_zinit.dither_arg = 0;
20731 81 temp_zinit.dither_percent = 20;
20732 81 temp_zinit.def_lightrad = 24;
20733 81 temp_zinit.transdark_percent = 0;
20734 }
20735
20736
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 24)
20737 {
20738
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.darkcol,f,true))
20739 {
20740 return qe_invalid;
20741 }
20742 23 }
20743 else
20744 {
20745 81 temp_zinit.darkcol = BLACK;
20746 }
20747
20748
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 25)
20749 {
20750
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.gravity2,f,true))
20751 {
20752 return qe_invalid;
20753 }
20754
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.swimgravity,f,true))
20755 {
20756 return qe_invalid;
20757 }
20758 23 }
20759 else
20760 {
20761 81 temp_zinit.gravity2 = temp_zinit.gravity*100;
20762 81 temp_zinit.swimgravity = 5;
20763 }
20764
20765
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 26)
20766 {
20767
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f,true))
20768 {
20769 return qe_invalid;
20770 }
20771
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f,true))
20772 {
20773 return qe_invalid;
20774 }
20775
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f,true))
20776 {
20777 return qe_invalid;
20778 }
20779 23 }
20780 else
20781 {
20782 81 temp_zinit.heroSideswimUpStep = 150;
20783 81 temp_zinit.heroSideswimSideStep = 100;
20784 81 temp_zinit.heroSideswimDownStep = 75;
20785 }
20786
20787
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 27)
20788 {
20789
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.exitWaterJump,f,true))
20790 {
20791 return qe_invalid;
20792 }
20793 23 }
20794 else
20795 {
20796 81 temp_zinit.exitWaterJump = 0;
20797 }
20798
20799
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 29)
20800 {
20801
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_igetl(&temp_zinit.bunny_ltm,f,true))
20802 {
20803 return qe_invalid;
20804 }
20805 23 }
20806 else
20807 {
20808 81 temp_zinit.bunny_ltm = 0;
20809 }
20810
20811
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 30)
20812 {
20813
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.switchhookstyle,f,true))
20814 {
20815 return qe_invalid;
20816 }
20817 23 }
20818 else
20819 {
20820 81 temp_zinit.switchhookstyle = 1;
20821 }
20822
20823
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 81 times.
104 if(s_version > 31)
20824 {
20825
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if(!p_getc(&temp_zinit.magicdrainrate,f,true))
20826 {
20827 return qe_invalid;
20828 }
20829 23 }
20830 else
20831 {
20832
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20833
1/2
✓ Branch 0 taken 81 times.
✗ Branch 1 not taken.
81 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20834 }
20835
20836
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 temp_zinit.clear_genscript();
20837
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 91 times.
104 if(s_version > 32)
20838 {
20839 13 word numgenscript = 0;
20840
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
13 if(!p_igetw(&numgenscript,f,true))
20841 return qe_invalid;
20842
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 1 times.
14 for(auto q = 1; q < numgenscript; ++q)
20843 {
20844
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getc(&padding,f,true))
20845 return qe_invalid;
20846
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!(padding&2))
20847 continue;
20848 1 temp_zinit.gen_doscript[q] = padding&1;
20849
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetw(&temp_zinit.gen_exitState[q],f,true))
20850 return qe_invalid;
20851
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_igetw(&temp_zinit.gen_reloadState[q],f,true))
20852 return qe_invalid;
20853
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 for(auto p = 0; p < 8; ++p)
20854
2/4
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
8 if(!p_igetl(&temp_zinit.gen_initd[q][p],f,true))
20855 return qe_invalid;
20856
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_dataSize[q],f,true))
20857 return qe_invalid;
20858
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f,true))
20859 return qe_invalid;
20860
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 if(!p_igetl(&temp_zinit.gen_eventstate[q],f,true))
20861 return qe_invalid;
20862 1 }
20863 13 }
20864
20865
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(keepdata==true)
20866 {
20867
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 zinit = temp_zinit;
20868
20869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(zinit.heroAnimationStyle==las_zelda3slow)
20870 {
20871 hero_animation_speed=2;
20872 }
20873 else
20874 {
20875 104 hero_animation_speed=1;
20876 }
20877 104 }
20878
20879 104 return 0;
20880 440 }
20881
20882 /*
20883 void setupitemdropsets()
20884 {
20885 for(int32_t i=0; i<isMAX; i++)
20886 {
20887 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20888 }
20889 }
20890 */
20891
20892 99 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build, bool keepdata)
20893 {
20894 99 build=build; // here to prevent compiler warnings
20895 dword dummy_dword;
20896 99 word item_drop_sets_to_read=0;
20897 item_drop_object tempitemdrop;
20898 99 word s_version=0, s_cversion=0;
20899
20900
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 99 times.
99 if(keepdata)
20901 {
20902
2/2
✓ Branch 0 taken 25344 times.
✓ Branch 1 taken 99 times.
25443 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20903 {
20904 25344 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20905 25344 }
20906 99 }
20907
20908
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 2 times.
99 if(version > 0x192)
20909 {
20910 97 item_drop_sets_to_read=0;
20911
20912 //section version info
20913
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_version,f,true))
20914 {
20915 return qe_invalid;
20916 }
20917
20918 97 FFCore.quest_format[vItemDropsets] = s_version;
20919
20920 //al_trace("Item drop sets version %d\n", s_version);
20921
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
20922 {
20923 return qe_invalid;
20924 }
20925
20926 //section size
20927
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy_dword,f,true))
20928 {
20929 return qe_invalid;
20930 }
20931
20932 //finally... section data
20933
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&item_drop_sets_to_read,f,true))
20934 {
20935 return qe_invalid;
20936 }
20937 97 }
20938 else
20939 {
20940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(keepdata==true)
20941 {
20942 2 init_item_drop_sets();
20943 2 }
20944 }
20945
20946
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 97 times.
99 if(s_version>=1)
20947 {
20948
2/2
✓ Branch 0 taken 1857 times.
✓ Branch 1 taken 97 times.
1954 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20949 {
20950
1/2
✓ Branch 0 taken 1857 times.
✗ Branch 1 not taken.
1857 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f,true))
20951 {
20952 return qe_invalid;
20953 }
20954
20955
2/2
✓ Branch 0 taken 18570 times.
✓ Branch 1 taken 1857 times.
20427 for(int32_t j=0; j<10; ++j)
20956 {
20957
1/2
✓ Branch 0 taken 18570 times.
✗ Branch 1 not taken.
18570 if(!p_igetw(&tempitemdrop.item[j],f,true))
20958 {
20959 return qe_invalid;
20960 }
20961 18570 }
20962
20963
2/2
✓ Branch 0 taken 20427 times.
✓ Branch 1 taken 1857 times.
22284 for(int32_t j=0; j<11; ++j)
20964 {
20965
1/2
✓ Branch 0 taken 20427 times.
✗ Branch 1 not taken.
20427 if(!p_igetw(&tempitemdrop.chance[j],f,true))
20966 {
20967 return qe_invalid;
20968 }
20969 20427 }
20970
20971 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20972 // overrides the quest's set #12.
20973
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1857 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1857 if(s_version<2 && i==12)
20974 continue;
20975
20976 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20977
1/4
✓ Branch 0 taken 1857 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1857 if(s_version<2) for(int32_t j=0; j<10; ++j)
20978 {
20979 int32_t it = tempitemdrop.item[j];
20980
20981 if((itemsbuf[it].family == itype_rupee
20982 && ((itemsbuf[it].amount)&0xFFF) == 10)
20983 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20984 {
20985 tempitemdrop.chance[j+1]=0;
20986 }
20987 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20988 {
20989 tempitemdrop.chance[j+1]=0;
20990 }
20991
20992 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20993 if(itemsbuf[it].family == itype_misc)
20994 {
20995 // If a non-gameplay item was selected, then item drop was aborted.
20996 // Reflect this by increasing the 'Nothing' chance accordingly.
20997 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20998 tempitemdrop.chance[j+1]=0;
20999 }
21000 }
21001
21002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1857 times.
1857 if(keepdata)
21003 {
21004 1857 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21005 1857 }
21006 1857 }
21007 97 }
21008
21009 99 return 0;
21010 99 }
21011
21012 97 int32_t readfavorites(PACKFILE *f, int32_t, word, bool keepdata)
21013 {
21014 int32_t temp_num;
21015 dword dummy_dword;
21016 word num_favorite_combos;
21017 word num_favorite_combo_aliases;
21018 97 word s_version=0, s_cversion=0;
21019
21020 //section version info
21021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(!p_igetw(&s_version,f,true))
21022 {
21023 return qe_invalid;
21024 }
21025
21026 97 FFCore.quest_format[vFavourites] = s_version;
21027
21028
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&s_cversion,f,true))
21029 {
21030 return qe_invalid;
21031 }
21032
21033 //section size
21034
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetl(&dummy_dword,f,true))
21035 {
21036 return qe_invalid;
21037 }
21038
21039 97 word per_row = FAVORITECOMBO_PER_ROW;
21040
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version >= 3)
21041 if(!p_igetw(&per_row,f,true))
21042 return qe_invalid;
21043 //finally... section data
21044
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&num_favorite_combos,f,true))
21045 {
21046 return qe_invalid;
21047 }
21048
21049 //Hack; port old favorite combos
21050
2/4
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 97 times.
97 if(s_version < 3 && num_favorite_combos == 100)
21051 97 per_row = 13;
21052
21053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata)
21054 {
21055
2/2
✓ Branch 0 taken 29100 times.
✓ Branch 1 taken 97 times.
29197 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21056 29100 favorite_combos[q] = -1;
21057
2/2
✓ Branch 0 taken 29100 times.
✓ Branch 1 taken 97 times.
29197 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21058 29100 favorite_comboaliases[q] = -1;
21059 97 }
21060
2/2
✓ Branch 0 taken 9700 times.
✓ Branch 1 taken 97 times.
9797 for(int32_t i=0; i<num_favorite_combos; i++)
21061 {
21062
1/2
✓ Branch 0 taken 9700 times.
✗ Branch 1 not taken.
9700 if(!p_igetl(&temp_num,f,true))
21063 {
21064 return qe_invalid;
21065 }
21066
21067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9700 times.
9700 if(keepdata)
21068 {
21069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9700 times.
9700 if(per_row == FAVORITECOMBO_PER_ROW)
21070 favorite_combos[i]=temp_num;
21071 else
21072 {
21073 9700 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21074 9700 favorite_combos[new_i]=temp_num;
21075 }
21076 9700 }
21077 9700 }
21078
21079
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(!p_igetw(&num_favorite_combo_aliases,f,true))
21080 {
21081 return qe_invalid;
21082 }
21083
21084
2/2
✓ Branch 0 taken 9700 times.
✓ Branch 1 taken 97 times.
9797 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21085 {
21086
1/2
✓ Branch 0 taken 9700 times.
✗ Branch 1 not taken.
9700 if(!p_igetl(&temp_num,f,true))
21087 {
21088 return qe_invalid;
21089 }
21090
21091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9700 times.
9700 if(keepdata)
21092 {
21093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9700 times.
9700 if(per_row == FAVORITECOMBO_PER_ROW)
21094 favorite_comboaliases[i]=temp_num;
21095 else
21096 {
21097 9700 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21098 9700 favorite_comboaliases[new_i]=temp_num;
21099 }
21100 9700 }
21101 9700 }
21102
21103 97 word max_combo_cols = 0;
21104 97 word max_mappages = 0;
21105
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(s_version >= 2)
21106 {
21107 if(!p_igetw(&max_combo_cols,f,true))
21108 return qe_invalid;
21109 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21110 for(int q = 0; q < max_combo_cols; ++q)
21111 {
21112 if(!p_igetl(&tmp,f,true))
21113 return qe_invalid;
21114 if(!p_igetl(&tmp2,f,true))
21115 return qe_invalid;
21116 if(!p_igetl(&tmp3,f,true))
21117 return qe_invalid;
21118 if(keepdata && q < MAX_COMBO_COLS)
21119 {
21120 First[q] = tmp;
21121 combo_alistpos[q] = tmp2;
21122 combo_pool_listpos[q] = tmp3;
21123 }
21124 }
21125
21126 if(!p_igetw(&max_mappages,f,true))
21127 return qe_invalid;
21128 for(int q = 0; q < max_mappages; ++q)
21129 {
21130 if(!p_igetl(&tmp,f,true))
21131 return qe_invalid;
21132 if(!p_igetl(&tmp2,f,true))
21133 return qe_invalid;
21134 if(keepdata && q < MAX_MAPPAGE_BTNS)
21135 {
21136 map_page[q].map = tmp;
21137 map_page[q].screen = tmp2;
21138 }
21139 }
21140 }
21141
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(keepdata)
21142 {
21143
2/2
✓ Branch 0 taken 388 times.
✓ Branch 1 taken 97 times.
485 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21144 {
21145 388 First[q] = 0;
21146 388 combo_alistpos[q] = 0;
21147 388 combo_pool_listpos[q] = 0;
21148 388 }
21149
2/2
✓ Branch 0 taken 873 times.
✓ Branch 1 taken 97 times.
970 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21150 {
21151 873 map_page[q].map = 0;
21152 873 map_page[q].screen = 0;
21153 873 }
21154 97 }
21155
21156 97 return 0;
21157 97 }
21158
21159 /*
21160 switch (ret) {
21161 case 0:
21162 break;
21163
21164 case qe_invalid:
21165 goto invalid;
21166 break;
21167 default:
21168 pack_fclose(f);
21169 if(!oldquest)
21170 delete_file(tmpfilename);
21171 return ret;
21172 break;
21173 }
21174 */
21175
21176 const char *skip_text[skip_max]=
21177 {
21178 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21179 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21180 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21181 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21182 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21183 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21184 "skip_favorites"
21185 };
21186
21187
21188 void port250QuestRules(){
21189
21190 portCandleRules(); //Candle
21191 portBombRules();
21192
21193 }
21194
21195 void portCandleRules()
21196 {
21197 bool hurtshero = get_bit(quest_rules,qr_FIREPROOFHERO);
21198 //itemdata itemsbuf;
21199 for ( int32_t q = 0; q < MAXITEMS; q++ )
21200 {
21201 if ( itemsbuf[q].family == itype_candle )
21202 {
21203 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21204 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21205 }
21206 }
21207 }
21208
21209 void portBombRules()
21210 {
21211 bool hurtshero = get_bit(quest_rules,qr_OUCHBOMBS);
21212 //itemdata itemsbuf;
21213 for ( int32_t q = 0; q < MAXITEMS; q++ )
21214 {
21215 if ( itemsbuf[q].family == itype_bomb )
21216 {
21217 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21218 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21219 }
21220 }
21221
21222 }
21223
21224 //Internal function for loadquest wrapper
21225 104 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, const byte *skip_flags, byte printmetadata)
21226 {
21227 104 DMapEditorLastMaptileUsed = 0;
21228 104 combosread=false;
21229 104 mapsread=false;
21230 104 fixffcs=false;
21231
21232
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(get_debug()&&(key[KEY_LSHIFT]||key[KEY_RSHIFT]))
21233 {
21234 keepall=false;
21235 jwin_alert("Load Quest","Data retention disabled.",NULL,NULL,"OK",NULL,13,27,get_zc_font(font_lfont));
21236 }
21237
21238 // show_progress=true;
21239 char tmpfilename[L_tmpnam];
21240 104 temp_name(tmpfilename);
21241 // char percent_done[30];
21242 104 bool catchup=false;
21243 byte tempbyte;
21244 104 word old_map_count=map_count;
21245
21246 104 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21247 104 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21248 104 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21249
21250
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall==false||get_bit(skip_flags, skip_rules))
21251 {
21252 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21253 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21254 }
21255
21256 104 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21257 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21258
21259
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall==false||get_bit(skip_flags, skip_midis))
21260 {
21261 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21262 }
21263
21264
21265
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_ffscript))
21266 {
21267 104 zScript.clear();
21268 104 globalmap.clear();
21269 104 genericmap.clear();
21270 104 ffcmap.clear();
21271 104 itemmap.clear();
21272 104 npcmap.clear();
21273 104 ewpnmap.clear();
21274 104 lwpnmap.clear();
21275 104 playermap.clear();
21276 104 dmapmap.clear();
21277 104 screenmap.clear();
21278 104 itemspritemap.clear();
21279 104 comboscriptmap.clear();
21280
21281
2/2
✓ Branch 0 taken 53144 times.
✓ Branch 1 taken 104 times.
53248 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21282 {
21283 53144 ffcmap[i].clear();
21284 53144 }
21285
21286 104 globalmap[0].slotname = "Slot 1:";
21287 104 globalmap[0].scriptname = "~Init";
21288 104 globalmap[0].update();
21289
21290
2/2
✓ Branch 0 taken 728 times.
✓ Branch 1 taken 104 times.
832 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21291 {
21292 728 globalmap[i].clear();
21293 728 }
21294
21295
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21296 {
21297 26520 itemmap[i].clear();
21298 26520 }
21299
21300 //new script types -- prevent carrying over to a quest that you load after reading them
21301 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21302
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21303 {
21304 26520 npcmap[i].clear();
21305 26520 }
21306
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21307 {
21308 26520 lwpnmap[i].clear();
21309 26520 }
21310
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21311 {
21312 26520 ewpnmap[i].clear();
21313 26520 }
21314
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
520 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21315 {
21316 416 playermap[i].clear();
21317 416 }
21318
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21319 {
21320 26520 dmapmap[i].clear();
21321 26520 }
21322
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21323 {
21324 26520 screenmap[i].clear();
21325 26520 }
21326
2/2
✓ Branch 0 taken 26520 times.
✓ Branch 1 taken 104 times.
26624 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21327 {
21328 26520 itemspritemap[i].clear();
21329 26520 }
21330
2/2
✓ Branch 0 taken 53144 times.
✓ Branch 1 taken 104 times.
53248 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21331 {
21332 53144 comboscriptmap[i].clear();
21333 53144 }
21334
2/2
✓ Branch 0 taken 53144 times.
✓ Branch 1 taken 104 times.
53248 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21335 {
21336 53144 genericmap[i].clear();
21337 53144 }
21338
21339 104 reset_scripts();
21340 104 }
21341
21342 zquestheader tempheader;
21343 104 memset(&tempheader, 0, sizeof(zquestheader));
21344 104 zinfo tempzi;
21345 104 tempzi.clear();
21346 104 load_tmp_zi = &tempzi;
21347
21348 // oldquest flag is set when an unencrypted qst file is suspected.
21349 104 bool oldquest = false;
21350 104 int32_t open_error=0;
21351 char deletefilename[1024];
21352 104 PACKFILE *f=open_quest_file(&open_error, filename, deletefilename, compressed, encrypted, show_progress);
21353
21354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!f)
21355 return open_error;
21356 char zinfofilename[2048];
21357 104 replace_extension(zinfofilename, filename, "zinfo", 2047);
21358 104 int32_t ret=0;
21359
21360 //header
21361 104 box_out("Reading Header...");
21362 104 ret=readheader(f, &tempheader, true, printmetadata);
21363
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
104 checkstatus(ret);
21364 104 box_out("okay.");
21365 104 box_eol();
21366
21367
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 23 times.
104 if(read_zinfo)
21368 {
21369 23 box_out("Reading ZInfo - ");
21370
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 box_out(read_ext_zinfo ? "External..." : "Internal...");
21371
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 22 times.
23 if(read_ext_zinfo)
21372 {
21373 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21374 1 ret=readzinfo(inf, tempzi, tempheader);
21375
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21376
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21377 1 }
21378 else
21379 {
21380 22 ret=readzinfo(f, tempzi, tempheader);
21381
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
22 checkstatus(ret);
21382 }
21383 23 box_out("okay.");
21384 23 box_eol();
21385 23 }
21386
21387
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if(tempheader.zelda_version>=0x193)
21388 {
21389 dword section_id;
21390
21391 //section id
21392
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(!p_mgetl(&section_id,f,true))
21393 {
21394 return qe_invalid;
21395 }
21396
21397
2/2
✓ Branch 0 taken 2403 times.
✓ Branch 1 taken 102 times.
2505 while(!pack_feof(f))
21398 {
21399
24/25
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
✓ Branch 2 taken 102 times.
✓ Branch 3 taken 102 times.
✓ Branch 4 taken 102 times.
✓ Branch 5 taken 102 times.
✓ Branch 6 taken 97 times.
✓ Branch 7 taken 102 times.
✓ Branch 8 taken 102 times.
✓ Branch 9 taken 102 times.
✓ Branch 10 taken 102 times.
✓ Branch 11 taken 102 times.
✓ Branch 12 taken 102 times.
✓ Branch 13 taken 97 times.
✓ Branch 14 taken 97 times.
✓ Branch 15 taken 102 times.
✓ Branch 16 taken 102 times.
✓ Branch 17 taken 97 times.
✓ Branch 18 taken 97 times.
✓ Branch 19 taken 97 times.
✓ Branch 20 taken 97 times.
✓ Branch 21 taken 102 times.
✓ Branch 22 taken 102 times.
✓ Branch 23 taken 97 times.
✓ Branch 24 taken 97 times.
2403 switch(section_id)
21400 {
21401 case ID_RULES:
21402
21403 //rules
21404
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21405 {
21406 box_out("found.");
21407 box_eol();
21408 catchup=false;
21409 }
21410
21411 102 box_out("Reading Rules...");
21412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21413
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21414 102 box_out("okay.");
21415 102 box_eol();
21416 102 break;
21417
21418 case ID_STRINGS:
21419
21420 //strings
21421
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21422 {
21423 box_out("found.");
21424 box_eol();
21425 catchup=false;
21426 }
21427
21428 102 box_out("Reading Strings...");
21429
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21430
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21431 102 box_out("okay.");
21432 102 box_eol();
21433 102 break;
21434
21435 case ID_MISC:
21436
21437 //misc data
21438
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21439 {
21440 box_out("found.");
21441 box_eol();
21442 catchup=false;
21443 }
21444
21445 102 box_out("Reading Misc. Data...");
21446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21447
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21448 102 box_out("okay.");
21449 102 box_eol();
21450 102 break;
21451
21452 case ID_TILES:
21453
21454 //tiles
21455
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21456 {
21457 box_out("found.");
21458 box_eol();
21459 catchup=false;
21460 }
21461
21462 102 box_out("Reading Tiles...");
21463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21464
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21465 102 box_out("okay.");
21466 102 box_eol();
21467 102 break;
21468
21469 case ID_COMBOS:
21470
21471 //combos
21472
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21473 {
21474 box_out("found.");
21475 box_eol();
21476 catchup=false;
21477 }
21478
21479 102 box_out("Reading Combos...");
21480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21481 102 combosread=true;
21482
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21483 102 box_out("okay.");
21484 102 box_eol();
21485 102 break;
21486
21487 case ID_COMBOALIASES:
21488
21489 //combo aliases
21490
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21491 {
21492 box_out("found.");
21493 box_eol();
21494 catchup=false;
21495 }
21496
21497 97 box_out("Reading Combo Aliases...");
21498
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_comboaliases));
21499
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21500 97 box_out("okay.");
21501 97 box_eol();
21502 97 break;
21503
21504 case ID_CSETS:
21505
21506 //color data
21507
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21508 {
21509 box_out("found.");
21510 box_eol();
21511 catchup=false;
21512 }
21513
21514 102 box_out("Reading Color Data...");
21515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21516
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21517 102 box_out("okay.");
21518 102 box_eol();
21519 102 break;
21520
21521 case ID_MAPS:
21522
21523 //maps
21524
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21525 {
21526 box_out("found.");
21527 box_eol();
21528 catchup=false;
21529 }
21530
21531 102 box_out("Reading Maps...");
21532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21533 102 mapsread=true;
21534
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21535 102 box_out("okay.");
21536 102 box_eol();
21537 102 break;
21538
21539 case ID_DMAPS:
21540
21541 //dmaps
21542
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21543 {
21544 box_out("found.");
21545 box_eol();
21546 catchup=false;
21547 }
21548
21549 102 box_out("Reading DMaps...");
21550
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21551
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21552 102 box_out("okay.");
21553 102 box_eol();
21554 102 break;
21555
21556 case ID_DOORS:
21557
21558 //door combo sets
21559
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21560 {
21561 box_out("found.");
21562 box_eol();
21563 catchup=false;
21564 }
21565
21566 102 box_out("Reading Doors...");
21567
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21568
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21569 102 box_out("okay.");
21570 102 box_eol();
21571 102 break;
21572
21573 case ID_ITEMS:
21574
21575 //items
21576
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21577 {
21578 box_out("found.");
21579 box_eol();
21580 catchup=false;
21581 }
21582
21583 102 box_out("Reading Items...");
21584
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21585
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21586
21587 102 box_out("okay.");
21588 102 box_eol();
21589 102 break;
21590
21591 case ID_WEAPONS:
21592
21593 //weapons
21594
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21595 {
21596 box_out("found.");
21597 box_eol();
21598 catchup=false;
21599 }
21600
21601 102 box_out("Reading Weapons...");
21602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21603
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21604 102 box_out("okay.");
21605 102 box_eol();
21606 102 break;
21607
21608 case ID_COLORS:
21609
21610 //misc. colors
21611
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21612 {
21613 box_out("found.");
21614 box_eol();
21615 catchup=false;
21616 }
21617
21618 97 box_out("Reading Misc. Colors...");
21619
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readmisccolors(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_colors));
21620
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21621 97 box_out("okay.");
21622 97 box_eol();
21623 97 break;
21624
21625 case ID_ICONS:
21626
21627 //game icons
21628
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21629 {
21630 box_out("found.");
21631 box_eol();
21632 catchup=false;
21633 }
21634
21635 97 box_out("Reading Game Icons...");
21636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readgameicons(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_icons));
21637
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21638 97 box_out("okay.");
21639 97 box_eol();
21640 97 break;
21641
21642 case ID_INITDATA:
21643
21644 //initialization data
21645
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21646 {
21647 box_out("found.");
21648 box_eol();
21649 catchup=false;
21650 }
21651
21652 102 box_out("Reading Init. Data...");
21653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21654
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21655 102 box_out("okay.");
21656 102 box_eol();
21657
21658
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21659 {
21660
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 18 times.
102 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21661 {
21662 18 setupsubscreens();
21663
21664
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t i=0; i<MAXDMAPS; ++i)
21665 {
21666 9216 int32_t type=DMaps[i].type&dmfTYPE;
21667
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 9123 times.
9216 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21668 9216 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21669 9216 }
21670 18 }
21671 102 }
21672
21673
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(keepall&&!get_bit(skip_flags, skip_sfx))
21674 {
21675 102 setupsfx();
21676 102 }
21677
21678
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(keepall&&!get_bit(skip_flags, skip_itemdropsets))
21679 {
21680 102 init_item_drop_sets();
21681 102 }
21682
21683
2/4
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 102 times.
102 if(keepall&&!get_bit(skip_flags, skip_favorites))
21684 {
21685 102 init_favorites();
21686 102 }
21687
21688 102 break;
21689
21690 case ID_GUYS:
21691
21692 //guys
21693
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21694 {
21695 box_out("found.");
21696 box_eol();
21697 catchup=false;
21698 }
21699
21700 102 box_out("Reading Custom Guy Data...");
21701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21702
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21703 102 box_out("okay.");
21704 102 box_eol();
21705 102 break;
21706
21707 case ID_HEROSPRITES:
21708
21709 //player sprites
21710
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21711 {
21712 box_out("found.");
21713 box_eol();
21714 catchup=false;
21715 }
21716
21717 97 box_out("Reading Custom Player Sprite Data...");
21718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readherosprites(f, &tempheader, keepall&&!get_bit(skip_flags, skip_herosprites));
21719
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21720 97 box_out("okay.");
21721 97 box_eol();
21722 97 break;
21723
21724 case ID_SUBSCREEN:
21725
21726 //custom subscreens
21727
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21728 {
21729 box_out("found.");
21730 box_eol();
21731 catchup=false;
21732 }
21733
21734 97 box_out("Reading Custom Subscreen Data...");
21735
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readsubscreens(f, &tempheader, keepall&&!get_bit(skip_flags, skip_subscreens));
21736
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21737 97 box_out("okay.");
21738 97 box_eol();
21739 97 break;
21740
21741 case ID_FFSCRIPT:
21742
21743 //Freeform combo scripts
21744
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21745 {
21746 box_out("found.");
21747 box_eol();
21748 catchup=false;
21749 }
21750
21751 97 box_out("Reading FF Script Data...");
21752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readffscript(f, &tempheader, keepall&&!get_bit(skip_flags, skip_ffscript));
21753
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21754 97 box_out("okay.");
21755 97 box_eol();
21756 97 break;
21757
21758 case ID_SFX:
21759
21760 //SFX data
21761
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21762 {
21763 box_out("found.");
21764 box_eol();
21765 catchup=false;
21766 }
21767
21768 97 box_out("Reading SFX Data...");
21769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readsfx(f, &tempheader, keepall&&!get_bit(skip_flags, skip_sfx));
21770
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21771 97 box_out("okay.");
21772 97 box_eol();
21773 97 break;
21774
21775 case ID_MIDIS:
21776
21777 //midis
21778
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21779 {
21780 box_out("found.");
21781 box_eol();
21782 catchup=false;
21783 }
21784
21785 102 box_out("Reading Tunes...");
21786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21787
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21788 102 box_out("okay.");
21789 102 box_eol();
21790 102 break;
21791
21792 case ID_CHEATS:
21793
21794 //cheat codes
21795
1/2
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
102 if(catchup)
21796 {
21797 box_out("found.");
21798 box_eol();
21799 catchup=false;
21800 }
21801
21802 102 box_out("Reading Cheat Codes...");
21803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102 times.
102 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21804
1/5
✓ Branch 0 taken 102 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
102 checkstatus(ret);
21805 102 box_out("okay.");
21806 102 box_eol();
21807 102 break;
21808
21809 case ID_ITEMDROPSETS:
21810
21811 //item drop sets
21812
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21813 {
21814 box_out("found.");
21815 box_eol();
21816 catchup=false;
21817 }
21818
21819 97 box_out("Reading Item Drop Sets...");
21820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_itemdropsets));
21821
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21822 97 box_out("okay.");
21823 97 box_eol();
21824 97 break;
21825
21826 case ID_FAVORITES:
21827
21828 //favorite combos and combo aliases
21829
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 if(catchup)
21830 {
21831 box_out("found.");
21832 box_eol();
21833 catchup=false;
21834 }
21835
21836 97 box_out("Reading Favorite Combos...");
21837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 ret=readfavorites(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_favorites));
21838
1/5
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
97 checkstatus(ret);
21839 97 box_out("okay.");
21840 97 box_eol();
21841 97 break;
21842
21843 default:
21844 if(!catchup)
21845 {
21846 box_out("Bad token! Searching...");
21847 box_eol();
21848 }
21849
21850 catchup=true;
21851 break;
21852 }
21853
21854
21855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403 times.
2403 if(catchup)
21856 {
21857 //section id
21858 section_id=(section_id<<8);
21859
21860 if(!p_getc(&tempbyte,f,true))
21861 {
21862 return qe_invalid;
21863 }
21864
21865 section_id+=tempbyte;
21866 }
21867
21868 else
21869 {
21870 //section id
21871
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2301 times.
2403 if(!pack_feof(f))
21872 {
21873
1/2
✓ Branch 0 taken 2301 times.
✗ Branch 1 not taken.
2301 if(!p_mgetl(&section_id,f,true))
21874 {
21875 return qe_invalid;
21876 }
21877 2301 }
21878 }
21879 }
21880 102 }
21881 else
21882 {
21883 //rules
21884 2 box_out("Reading Rules...");
21885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readrules(f, &tempheader, keepall&&!get_bit(skip_flags, skip_rules));
21886
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21887 2 box_out("okay.");
21888 2 box_eol();
21889
21890 //strings
21891 2 box_out("Reading Strings...");
21892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readstrings(f, &tempheader, keepall&&!get_bit(skip_flags, skip_strings));
21893
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21894 2 box_out("okay.");
21895 2 box_eol();
21896
21897 //door combo sets
21898 2 box_out("Reading Doors...");
21899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readdoorcombosets(f, &tempheader, keepall&&!get_bit(skip_flags, skip_doors));
21900
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21901 2 box_out("okay.");
21902 2 box_eol();
21903
21904 //dmaps
21905 2 box_out("Reading DMaps...");
21906
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS, keepall&&!get_bit(skip_flags, skip_dmaps));
21907
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21908 2 box_out("okay.");
21909 2 box_eol();
21910
21911 // misc data
21912 2 box_out("Reading Misc. Data...");
21913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readmisc(f, &tempheader, Misc, keepall&&!get_bit(skip_flags, skip_misc));
21914
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21915 2 box_out("okay.");
21916 2 box_eol();
21917
21918 //items
21919 2 box_out("Reading Items...");
21920
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readitems(f, tempheader.zelda_version, tempheader.build, keepall&&!get_bit(skip_flags, skip_items));
21921
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21922 2 box_out("okay.");
21923 2 box_eol();
21924
21925 //weapons
21926 2 box_out("Reading Weapons...");
21927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readweapons(f, &tempheader, keepall&&!get_bit(skip_flags, skip_weapons));
21928
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21929 2 box_out("okay.");
21930 2 box_eol();
21931
21932 //guys
21933 2 box_out("Reading Custom Guy Data...");
21934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readguys(f, &tempheader, keepall&&!get_bit(skip_flags, skip_guys));
21935
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21936 2 box_out("okay.");
21937 2 box_eol();
21938
21939 //maps
21940 2 box_out("Reading Maps...");
21941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readmaps(f, &tempheader, keepall&&!get_bit(skip_flags, skip_maps));
21942 2 mapsread=true;
21943
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21944 2 box_out("okay.");
21945 2 box_eol();
21946
21947 //combos
21948 2 box_out("Reading Combos...");
21949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS, keepall&&!get_bit(skip_flags, skip_combos));
21950 2 combosread=true;
21951
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21952 2 box_out("okay.");
21953 2 box_eol();
21954
21955 //color data
21956 2 box_out("Reading Color Data...");
21957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL, keepall&&!get_bit(skip_flags, skip_csets));
21958
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21959 2 box_out("okay.");
21960 2 box_eol();
21961
21962 //tiles
21963 2 box_out("Reading Tiles...");
21964
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false, keepall&&!get_bit(skip_flags, skip_tiles));
21965
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21966 2 box_out("okay.");
21967 2 box_eol();
21968
21969 //midis
21970 2 box_out("Reading Tunes...");
21971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readtunes(f, &tempheader, tunes, keepall&&!get_bit(skip_flags, skip_midis));
21972
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21973 2 box_out("okay.");
21974 2 box_eol();
21975
21976 //cheat codes
21977 2 box_out("Reading Cheat Codes...");
21978
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readcheatcodes(f, &tempheader, keepall&&!get_bit(skip_flags, skip_cheats));
21979
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21980 2 box_out("okay.");
21981 2 box_eol();
21982
21983 //initialization data
21984 2 box_out("Reading Init. Data...");
21985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readinitdata(f, &tempheader, keepall&&!get_bit(skip_flags, skip_initdata));
21986
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
21987 2 box_out("okay.");
21988 2 box_eol();
21989
21990
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(keepall&&!get_bit(skip_flags, skip_subscreens))
21991 {
21992 2 setupsubscreens();
21993
21994
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 2 times.
1026 for(int32_t i=0; i<MAXDMAPS; ++i)
21995 {
21996 1024 int32_t type=DMaps[i].type&dmfTYPE;
21997
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1016 times.
1024 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21998 1024 DMaps[i].passive_subscreen=(get_bit(quest_rules,qr_ENABLEMAGIC))?0:1;
21999 1024 }
22000 2 }
22001
22002 2 box_out("Setting Up Default Sound Effects...");
22003
22004
2/4
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
2 if(keepall&&!get_bit(skip_flags, skip_sfx))
22005 2 setupsfx();
22006
22007 2 box_out("okay.");
22008 2 box_eol();
22009
22010 //player sprites
22011 2 box_out("Reading Custom Player Sprite Data...");
22012
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 ret=readherosprites2(f, -1, 0, keepall&&!get_bit(skip_flags, skip_herosprites));
22013
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
2 checkstatus(ret);
22014 2 box_out("okay.");
22015 2 box_eol();
22016
22017 2 box_out("Setting Up Default Item Drop Sets...");
22018
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 ret=readitemdropsets(f, -1, 0, keepall&&!get_bit(skip_flags, skip_itemdropsets));
22019 2 box_out("okay.");
22020 2 box_eol();
22021 }
22022
22023 104 init_spritelists();
22024
22025 // check data
22026
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(f)
22027 {
22028 104 pack_fclose(f);
22029 104 }
22030
22031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
104 if(!oldquest)
22032 {
22033
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if(exists(tmpfilename))
22034 {
22035 delete_file(tmpfilename);
22036 }
22037 104 }
22038
22039
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
104 if(fixffcs && combosread && mapsread)
22040 {
22041 for(int32_t i=0; i<map_count; i++)
22042 {
22043 for(int32_t j=0; j<MAPSCRS; j++)
22044 {
22045 for(int32_t m=0; m<32; m++)
22046 {
22047 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22048 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22049 }
22050 }
22051 }
22052 }
22053
22054
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 20 times.
104 if(get_bit(quest_rules, qr_CONTFULL_DEP))
22055 {
22056 20 set_bit(quest_rules, qr_CONTFULL_DEP, 0);
22057 20 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22058 20 zinit.cont_heart=100;
22059 20 zinit.start_heart=zinit.hc;
22060 20 }
22061
22062 104 box_out("Done.");
22063 104 box_eol();
22064 104 box_end(false);
22065
22066 // if (keepall==true||!get_bit(skip_flags, skip_header))
22067
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_header))
22068 {
22069 104 memcpy(Header, &tempheader, sizeof(tempheader));
22070 104 }
22071
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(keepall&&!get_bit(skip_flags, skip_zinfo))
22072 {
22073 104 ZI.copyFrom(tempzi);
22074 104 }
22075
22076
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(!keepall||get_bit(skip_flags, skip_maps))
22077 {
22078 map_count=old_map_count;
22079 }
22080
22081
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(!keepall||get_bit(skip_flags, skip_rules))
22082 {
22083 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22084 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22085 }
22086
22087
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 104 times.
104 if(!keepall||get_bit(skip_flags, skip_midis))
22088 {
22089 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22090 }
22091
22092
2/4
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
104 if(deletefilename[0] && exists(deletefilename))
22093 {
22094 104 delete_file(deletefilename);
22095 104 }
22096
22097 //Debug FFCore.quest_format[]
22098 104 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22099 104 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22100 104 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22101 104 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22102 104 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22103 104 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22104 104 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22105 104 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22106 104 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22107 104 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22108 104 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22109 104 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22110 104 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22111 104 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22112 104 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22113 104 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22114 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22115 104 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22116 104 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22117 104 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22118 104 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22119 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22120 104 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22121 104 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22122 104 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22123 104 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22124 104 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22125 104 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22126 104 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22127 104 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22128 //Print metadata for versions under 2.10 here. Bleah.
22129
2/2
✓ Branch 0 taken 102 times.
✓ Branch 1 taken 2 times.
104 if( FFCore.quest_format[vZelda] < 0x210 )
22130 {
22131 2 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22132
22133
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
2 switch(FFCore.quest_format[vZelda])
22134 {
22135 case 0x193:
22136 {
22137 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22138 }
22139 case 0x192:
22140 {
22141 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22142 }
22143 case 0x190:
22144 {
22145 2 zprint2("Last saved in ZC Editor Version: 1.90");
22146
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22147 2 else zprint2("\n");
22148 2 break;
22149 }
22150 case 0x188:
22151 {
22152 zprint2("Last saved in ZC Editor Version: 1.88");
22153 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22154 else zprint2("\n");
22155 break;
22156 }
22157 case 0x187:
22158 {
22159 zprint2("Last saved in ZC Editor Version: 1.87");
22160 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22161 else zprint2("\n");
22162 break;
22163 }
22164 case 0x186:
22165 {
22166 zprint2("Last saved in ZC Editor Version: 1.86");
22167 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22168 else zprint2("\n");
22169 break;
22170 }
22171 case 0x185:
22172 {
22173 zprint2("Last saved in ZC Editor Version: 1.85");
22174 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22175 else zprint2("\n");
22176 break;
22177 }
22178 case 0x184:
22179 {
22180 zprint2("Last saved in ZC Editor Version: 1.84");
22181 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22182 else zprint2("\n");
22183 break;
22184 }
22185 case 0x183:
22186 {
22187 zprint2("Last saved in ZC Editor Version: 1.83");
22188 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22189 else zprint2("\n");
22190 break;
22191 }
22192 case 0x182:
22193 {
22194 zprint2("Last saved in ZC Editor Version: 1.82");
22195 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22196 else zprint2("\n");
22197 break;
22198 }
22199 case 0x181:
22200 {
22201 zprint2("Last saved in ZC Editor Version: 1.81");
22202 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22203 else zprint2("\n");
22204 break;
22205 }
22206 case 0x180:
22207 {
22208 zprint2("Last saved in ZC Editor Version: 1.80");
22209 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22210 else zprint2("\n");
22211 break;
22212 }
22213 default:
22214 {
22215 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22216 }
22217 }
22218 2 }
22219
22220 104 return qe_OK;
22221
22222 invalid:
22223 box_out("error.");
22224 box_eol();
22225 box_end(true);
22226
22227 if(f)
22228 {
22229 pack_fclose(f);
22230 }
22231
22232 if(!oldquest)
22233 {
22234 if(exists(tmpfilename))
22235 {
22236 delete_file(tmpfilename);
22237 }
22238
22239 if(deletefilename[0] && exists(deletefilename))
22240 {
22241 delete_file(deletefilename);
22242 }
22243 }
22244
22245 return qe_invalid;
22246
22247 104 }
22248
22249 104 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, bool compressed, bool encrypted, bool keepall, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22250 {
22251 104 loading_qst_name = filename;
22252 104 loading_qst_num = qst_num;
22253 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22254 // So to avoid a more-recently update .qst file from hitting the "last saved in a newer version" prompt, we disable for replaying.
22255
1/2
✓ Branch 0 taken 104 times.
✗ Branch 1 not taken.
104 if (!replay_is_replaying())
22256 loadquest_report = report;
22257 104 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, compressed, encrypted, keepall, skip_flags,printmetadata);
22258 104 load_tmp_zi = NULL;
22259 104 loading_qst_name = NULL;
22260 104 loadquest_report = false;
22261 104 loading_qst_num = 0;
22262 104 return ret;
22263 }
22264 /*** end of qst.cc ***/
22265
22266